blob: 700c80cd57447a740f0e4cef797d08e4187c52bf [file] [log] [blame]
Antoine Pitroud9dfaa92009-06-04 20:32:06 +00001# This module is used to map the old Python 2 names to the new names used in
2# Python 3 for the pickle module. This needed to make pickle streams
3# generated with Python 2 loadable by Python 3.
4
5# This is a copy of lib2to3.fixes.fix_imports.MAPPING. We cannot import
6# lib2to3 and use the mapping defined there, because lib2to3 uses pickle.
7# Thus, this could cause the module to be imported recursively.
8IMPORT_MAPPING = {
9 'StringIO': 'io',
10 'cStringIO': 'io',
11 'cPickle': 'pickle',
12 '__builtin__' : 'builtins',
13 'copy_reg': 'copyreg',
14 'Queue': 'queue',
15 'SocketServer': 'socketserver',
16 'ConfigParser': 'configparser',
17 'repr': 'reprlib',
18 'FileDialog': 'tkinter.filedialog',
19 'tkFileDialog': 'tkinter.filedialog',
20 'SimpleDialog': 'tkinter.simpledialog',
21 'tkSimpleDialog': 'tkinter.simpledialog',
22 'tkColorChooser': 'tkinter.colorchooser',
23 'tkCommonDialog': 'tkinter.commondialog',
24 'Dialog': 'tkinter.dialog',
25 'Tkdnd': 'tkinter.dnd',
26 'tkFont': 'tkinter.font',
27 'tkMessageBox': 'tkinter.messagebox',
28 'ScrolledText': 'tkinter.scrolledtext',
29 'Tkconstants': 'tkinter.constants',
30 'Tix': 'tkinter.tix',
31 'ttk': 'tkinter.ttk',
32 'Tkinter': 'tkinter',
33 'markupbase': '_markupbase',
34 '_winreg': 'winreg',
35 'thread': '_thread',
36 'dummy_thread': '_dummy_thread',
37 'dbhash': 'dbm.bsd',
38 'dumbdbm': 'dbm.dumb',
39 'dbm': 'dbm.ndbm',
40 'gdbm': 'dbm.gnu',
41 'xmlrpclib': 'xmlrpc.client',
42 'DocXMLRPCServer': 'xmlrpc.server',
43 'SimpleXMLRPCServer': 'xmlrpc.server',
44 'httplib': 'http.client',
45 'htmlentitydefs' : 'html.entities',
46 'HTMLParser' : 'html.parser',
47 'Cookie': 'http.cookies',
48 'cookielib': 'http.cookiejar',
49 'BaseHTTPServer': 'http.server',
50 'SimpleHTTPServer': 'http.server',
51 'CGIHTTPServer': 'http.server',
52 'test.test_support': 'test.support',
53 'commands': 'subprocess',
54 'UserString' : 'collections',
55 'UserList' : 'collections',
56 'urlparse' : 'urllib.parse',
57 'robotparser' : 'urllib.robotparser',
58 'whichdb': 'dbm',
59 'anydbm': 'dbm'
60}
61
62
63# This contains rename rules that are easy to handle. We ignore the more
64# complex stuff (e.g. mapping the names in the urllib and types modules).
65# These rules should be run before import names are fixed.
66NAME_MAPPING = {
67 ('__builtin__', 'xrange'): ('builtins', 'range'),
68 ('__builtin__', 'reduce'): ('functools', 'reduce'),
69 ('__builtin__', 'intern'): ('sys', 'intern'),
70 ('__builtin__', 'unichr'): ('builtins', 'chr'),
71 ('__builtin__', 'basestring'): ('builtins', 'str'),
72 ('__builtin__', 'long'): ('builtins', 'int'),
73 ('itertools', 'izip'): ('builtins', 'zip'),
74 ('itertools', 'imap'): ('builtins', 'map'),
75 ('itertools', 'ifilter'): ('builtins', 'filter'),
76 ('itertools', 'ifilterfalse'): ('itertools', 'filterfalse'),
77}
78
79# Same, but for 3.x to 2.x
80REVERSE_IMPORT_MAPPING = dict((v, k) for (k, v) in IMPORT_MAPPING.items())
81REVERSE_NAME_MAPPING = dict((v, k) for (k, v) in NAME_MAPPING.items())