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
core: python3: need mechanism to avoid stdlib imports #265
Comments
Python 3.x ships _compat_pickle, which maps many (all?) renamed modules. The file comments say it's a copy of lib2to3.fixes.fix_imports. I haven't checked how much the two have diverged. |
O Pickle the thorn in my side, O Pickle the solution in my hand! Really awesome find :) I'm not sure I quite grok the format, but it looks like the child may just need a copy of the IMPORT_MAPPING dict keys. I'm a bit foggy just now, but I /think/ the same list (or perhaps a transform of it) can be used for the other direction too? 2.x child -> 3.x host |
>>> import _compat_pickle
>>> python2_modules = sorted(_compat_pickle.IMPORT_MAPPING.keys())
>>> '|'.join(python2_modules)
'BaseHTTPServer|CGIHTTPServer|ConfigParser|Cookie|Dialog|DocXMLRPCServer|FileDialog|HTMLParser|Queue|ScrolledText|SimpleDialog|SimpleHTTPServer|SimpleXMLRPCServer|SocketServer|StringIO|Tix|Tkconstants|Tkdnd|Tkinter|UserDict|UserList|UserString|__builtin__|_abcoll|_elementtree|_winreg|anydbm|cPickle|cStringIO|commands|cookielib|copy_reg|dbhash|dbm|dumbdbm|dummy_thread|gdbm|htmlentitydefs|httplib|markupbase|repr|robotparser|test.test_support|thread|tkColorChooser|tkCommonDialog|tkFileDialog|tkFont|tkMessageBox|tkSimpleDialog|ttk|urllib2|urlparse|whichdb|xmlrpclib' Running that through regex-opt gives
|
Alternatively https://github.com/jackmaney/python-stdlib-list has lists for Python 2.6-2.7 and 3.2-3.6 |
adding nigeria server configration files for server migration only r…
See also: #16
Given 'import urlparse' running on a 3.x target, this should raise ImportError. Instead it is forwarded to the 2.x host which then attempts to serve it, resulting in a syntax error.
python3 branch has a check within ModuleResponder to refuse any import from the standard library, but this costs a network round-trip. Need a complete list of renamed stdlib modules in core.py, and to select between them at startup. The inverse of this situation is true -- 2.x target will attempt to import 3.x host's stdlib too.
https://www.python.org/dev/peps/pep-3108/#previously-deprecated-done
The text was updated successfully, but these errors were encountered: