Fixes #428 - pwndbg.memory.write encoding error (#432)

It seems that pwndbg.memory.write fix for Py2 introduced in 433bf231
wasn't tested properly on Py3.

In Py2 by default the `bytes` is just `str` and so doesn't accept the encoding argument.

Because of that a `from builtins import bytes` has been added.

Some more info on `builtins` module can be found here: http://python-future.org/imports.html#imports-of-builtins
pull/433/head
Disconnect3d 8 years ago committed by GitHub
parent f63a69d474
commit 1a5e1347ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,6 +9,7 @@ from __future__ import print_function
from __future__ import unicode_literals
import os
from builtins import bytes
import gdb
@ -99,7 +100,7 @@ def write(addr, data):
addr(int): Address to write
data(str,bytes,bytearray): Data to write
"""
gdb.selected_inferior().write_memory(addr, bytes(data))
gdb.selected_inferior().write_memory(addr, bytes(data, 'utf8'))
def peek(address):

Loading…
Cancel
Save