[pywin32-checkins] pywin32/win32/Lib pywintypes.py, 1.13.2.1, 1.13.2.2
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2009-01-27 07:56:56
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv19500/win32/Lib Modified Files: Tag: py3k pywintypes.py Log Message: merge various trunk changes Index: pywintypes.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/pywintypes.py,v retrieving revision 1.13.2.1 retrieving revision 1.13.2.2 diff -C2 -d -r1.13.2.1 -r1.13.2.2 *** pywintypes.py 29 Aug 2008 04:59:25 -0000 1.13.2.1 --- pywintypes.py 27 Jan 2009 07:56:45 -0000 1.13.2.2 *************** *** 1,5 **** # Magic utility that "redirects" to pywintypesxx.dll import imp, sys, os - sys.modules['pywintypes_loader']=sys.modules['pywintypes'] def __import_pywin32_system_module__(modname, globs): # This has been through a number of iterations. The problem: how to --- 1,4 ---- *************** *** 32,35 **** --- 31,36 ---- (ext, mode, ext_type)) # and fill our namespace with it. + # XXX - if this ever moves to py3k, this will probably + # need similar adjustments as below... globs.update(mod.__dict__) return *************** *** 96,109 **** # give up in disgust. raise ImportError("No system module '%s' (%s)" % (modname, filename)) # Python can load the module - ## print ('__import_pywin32_system_module__ (before):', __import_pywin32_system_module__) mod = imp.load_dynamic(modname, found) ! ## print ('mod:', mod) ! ## print ('__import_pywin32_system_module__ (after):', __import_pywin32_system_module__) ! # and fill our namespace with it. ! # This doesn't work in py3k, where pywintypes actually ends up as the compiled pyd ! # which is loaded, rather than this script ! ## globs.update(mod.__dict__) ! mod.__import_pywin32_system_module__ = __import_pywin32_system_module__ ! __import_pywin32_system_module__("pywintypes", {}) --- 97,124 ---- # give up in disgust. raise ImportError("No system module '%s' (%s)" % (modname, filename)) + # py2k and py3k differences: + # On py2k, after doing "imp.load_module('pywintypes')", sys.modules + # is unchanged - ie, sys.modules['pywintypes'] still refers to *this* + # .py module - but the module's __dict__ has *already* need updated + # with the new module's contents. + # However, on py3k, sys.modules *is* changed - sys.modules['pywintypes'] + # will be changed to the new module object. + # SO: * on py2k don't need to update any globals. + # * on py3k we update our module dict with the new module's dict and + # copy its globals to ours. + old_mod = sys.modules[modname] # Python can load the module mod = imp.load_dynamic(modname, found) ! # Check the sys.modules[] behaviour we describe above is true... ! if sys.version_info < (3,0): ! assert sys.modules[modname] is old_mod ! assert mod is old_mod ! else: ! assert sys.modules[modname] is not old_mod ! assert sys.modules[modname] is mod ! # as above - re-reset to the *old* module object then update globs. ! sys.modules[modname] = old_mod ! globs.update(mod.__dict__) ! ! __import_pywin32_system_module__("pywintypes", globals()) |