Skip to content

reset stdin/out/err when reloading sys #593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed

Conversation

thomasballinger
Copy link
Member

fixes #567

@sebastinas
Copy link
Contributor

The code does not work:

bpython version 0.15.dev127 on top of Python 3.4.4 /usr/bin/python3
>>> import Crypto
>>> import importlib
>>> importlib.reload(Crypto)
Traceback (most recent call last):
  File "<bpython-input-4>", line 1, in <module>
    importlib.reload(Crypto)
  File "/home/sebastian/development/bpython/bpython/curtsiesfrontend/sitefix.py", line 42, in reload
    builtins.reload(sys)
AttributeError: 'module' object has no attribute 'reload'

@thomasballinger
Copy link
Member Author

  • correctly finds reload on Python 3.4
  • adds tests that new reload works
  • only does the monkeypatch on Python 2 because sys.stdout isn't replaced on reload(sys) in Python 3

@thomasballinger
Copy link
Member Author

I'd like to merge or close this soon. I'm happy with it now, and although it's a lot of code, the monkeypatching of reload only happens in Python 2 so we're mostly adding cruft to old Python. I don't understand how useful the use case is, see #567 (comment) for rationale.

@sebastinas
Copy link
Contributor

I'm not sure about this, but if you want it for 0.16, please merge it soon.

@thomasballinger
Copy link
Member Author

It's just adding cruft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

output abnormal after reload(sys)
2 participants