Repository navigation
bpython interpreter with pwn module #612
Copy link
Copy link
Closed
Description
I don't know is this problem has been asked. Here is my problem.
>>> from pwn import *
Traceback (most recent call last):
File "<input>", line 1, in <module>
from pwn import *
File "/usr/lib/python2.7/dist-packages/bpython/curtsiesfrontend/repl.py", line 257, in load_module
module = pkgutil.ImpLoader.load_module(self, name)
File "/usr/lib/python2.7/pkgutil.py", line 246, in load_module
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/usr/local/lib/python2.7/dist-packages/pwn/__init__.py", line 2, in <module>
from .toplevel import *
File "/usr/local/lib/python2.7/dist-packages/pwn/toplevel.py", line 2, in <module>
from pwnlib import *
File "/usr/lib/python2.7/dist-packages/bpython/curtsiesfrontend/repl.py", line 257, in load_module
module = pkgutil.ImpLoader.load_module(self, name)
File "/usr/lib/python2.7/pkgutil.py", line 246, in load_module
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/usr/local/lib/python2.7/dist-packages/pwnlib/__init__.py", line 10, in <module>
from . import \
File "/usr/local/lib/python2.7/dist-packages/pwnlib/asm.py", line 45, in <module>
from . import log
File "/usr/local/lib/python2.7/dist-packages/pwnlib/log.py", line 69, in <module>
from .term import spinners, text
File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/__init__.py", line 1, in <module>
from . import key, readline, text, termcap, keymap, term
File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/readline.py", line 2, in <module>
from . import term, text
File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/text.py", line 111, in <module>
sys.modules[__name__] = Module()
File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/text.py", line 22, in __init__
self.num_colors = termcap.get('colors', default = 8)
File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/termcap.py", line 15, in get
init()
File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/termcap.py", line 39, in init
curses.setupterm()
TypeError: argument must be an int, or have a fileno() method.
but with the python, ipython it runs OK.
ipython interpreter
In [1]: from pwn import *
In [2]:
python default interpreter
>>> from pwn import *
>>>
≻ bpython -V
bpython version 0.15 on top of Python 2.7.11+
(C) 2008-2015 Bob Farrell, Andreas Stuehrk et al. See AUTHORS for detail.
So it's not the problem with the pwn module, how can solve this problem? it's the bpython bug ? is anyone has problem with me,please tell me how to solve.thanks
Metadata
Metadata
Assignees
Labels
No labels
Activity
not-napoleon commentedon Jun 3, 2016
I'm having the same issue trying to use ansible:
As with the OP, it works fine from ipython.
calebstewart commentedon Jun 5, 2016
The issue is that bpython replaces
sys.stdoutwith an object calledFakeOutputand somewhere down the line in pwntools, tries to blindly use thesys.stdout.filenomethod. According to the standard, this method is not required. The only thing that is required of sys.stdout is awritemethod. That being said, I've created a fix for this as seen in this pull request. It's not the best solution, since FakeInput shouldn't be required to implement this, but it doesn't break anything and allows you to import pwntools. I'd say it's a good compromise. My fix also will correctly return1forsys.stdoutand2forsys.stderr.That being said, logging with pwntools will still be broken, because curtsies does not properly parse the reset escape sequence. Again, I've created a pull request for curtsies to correct this issue as well. With both of these changes, importing pwntools works great on my machine.
B0y1n4o4 commentedon Jun 6, 2016
year, now i update the bpython,it works well now. thank you !! @caleb1994