[Python-checkins] r63042 - in python/trunk: Lib/copy.py Lib/copy_reg.py Lib/copyreg.py Lib/idlelib/rpc.py Lib/os.py Lib/pickle.py Lib/re.py Lib/test/pickletester.py Lib/test/regrtest.py Lib/test/test___all__.py Lib/test/test_copy.py Lib/test/test

M.-A. Lemburg mal at egenix.com
Sun May 11 23:53:20 CEST 2008


On 2008-05-11 21:47, Brett Cannon wrote:
> On Sun, May 11, 2008 at 9:43 PM, Alexandre Vassalotti
> <alexandre at peadrop.com> wrote:
>> On Sun, May 11, 2008 at 3:15 PM, M.-A. Lemburg <mal at egenix.com> wrote:
>>> Ah, right: __dict__ is only available *after* the module has been
>>> loaded.
>>>
>>> This works:
>>>
>>> import copyreg
>>> locals().update(copyreg.__dict__)
>>>
>> Looks good to me. Brett, what do you think? Should we use that instead?
> 
> No because it doesn't solve the module identity problem. The proposed
> solution deals with that and continues to work with ``from ...
> import`` statements.

That's true, just thought that the sys.modules hack is a bit
fragile, e.g. in the case where

from copy_reg import pickle

is run for the first time in a fresh Python interpreter.

The above works (I just tested it), but the reason for it working
is a bit mysterious.

IMO, there should be a test case for to check that these imports actually
do work as expected. Not so much for the current implementation, but
to detect changes to the import mechanism which affect this hack.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 11 2008)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
            Registered at Amtsgericht Duesseldorf: HRB 46611


More information about the Python-checkins mailing list