mirror of https://github.com/pwndbg/pwndbg
Python2 no likey
This commit is contained in:
parent
18aa627d31
commit
9ea31293e6
|
@ -13,24 +13,18 @@ import gdb
|
|||
import pwndbg.compat
|
||||
|
||||
def get(fd, mode):
|
||||
if pwndbg.compat.python3:
|
||||
file = io.open(fd, mode=mode, buffering=0, closefd=False)
|
||||
return io.TextIOWrapper(file, write_through=True)
|
||||
else:
|
||||
return os.fdopen(fd, mode, 0)
|
||||
|
||||
stdin = get(0, 'rb')
|
||||
stdout = get(1, 'wb')
|
||||
stderr = get(2, 'wb')
|
||||
file = io.open(fd, mode=mode, buffering=0, closefd=False)
|
||||
return io.TextIOWrapper(file, write_through=True)
|
||||
|
||||
class Stdio(object):
|
||||
queue = []
|
||||
|
||||
def __enter__(self, *a, **kw):
|
||||
self.queue.append((sys.stdin, sys.stdout, sys.stderr))
|
||||
sys.stdin = get(0, 'rb')
|
||||
sys.stdout = get(1, 'wb')
|
||||
sys.stderr = get(2, 'wb')
|
||||
if pwndbg.compat.python3:
|
||||
sys.stdin = get(0, 'rb')
|
||||
sys.stdout = get(1, 'wb')
|
||||
sys.stderr = get(2, 'wb')
|
||||
|
||||
def __exit__(self, *a, **kw):
|
||||
sys.stdin, sys.stdout, sys.stderr = self.queue.pop()
|
||||
|
|
Loading…
Reference in New Issue