-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
sys.modules unpatching more trouble than it's worth #141
Comments
+1 |
wickman
added a commit
to wickman/pex
that referenced
this issue
Aug 4, 2015
wickman
added a commit
that referenced
this issue
Aug 4, 2015
Address #141. Update version.py to reflect 1.0.2.dev0.
lorencarvalho
added a commit
to lorencarvalho/pex
that referenced
this issue
Oct 8, 2015
* upstream/master: Migrate to the new travis-ci infra. [docs] update header in index.rst Add docs, change default behavior to use namesake command as pex. bdist_pex: Nicer output filename Don't choke if pkg has no console_scripts Allows --pex-args to take an argument Initial implementation of bdist_pex. Fix missed mock of safe_mkdir. Pin pytest to 2.5.2. Add pex-identifying User-Agent to requests sessions. Fix the docs release headers. Normalize all names in ResolvableSet. Fixes pex-tool#147. Release 1.0.3 Fix pex-tool#139: PEX_SCRIPT fails for scripts from not-zip-safe eggs. Fix a logging typo when determining the minimum sys.path Remove unnecessary stderr print on SystemExit().code == None Bump the pre-release version and update the change log. Accomodate OSX `Python` python binaries. Release 1.0.2 Address pex-tool#141. Update version.py to reflect 1.0.2.dev0. Fix from_env to capture only explicitly set values.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pex/pex.py has the following gem:
The first patch_all replaces the global sys.path, sys.path_importer_cache and sys.modules. This is fine, but the second patch_all replaces sys.modules with the original set, and thus de-refcounting all the modules that were imported during the lifecycle of the PEX. If you've registered
sys.excepthook
,atexit
handlers or__del__
, chances are you've seen inscrutable exceptions like'NoneType' object has no attribute 'TBinaryProtocolAccelerated'
or something. This is because of CPython interpreter teardown behavior: https://bugs.python.org/issue18214. This has since been "fixed" in CPython 3.4 but we can't mandate its use for everyone.I'm proposing that we get rid of the unpatch. It is only used during PEX.execute, which behaves like "exec()" and should be the last call in any sensible program. I can't think of any reason to keep it other than some misguided sense of functional purity.
The text was updated successfully, but these errors were encountered: