[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 21:15:08 CEST 2008


On 2008-05-11 20:23, Alexandre Vassalotti wrote:
> On Sun, May 11, 2008 at 7:23 AM, M.-A. Lemburg <mal at egenix.com> wrote:
>> On 2008-05-11 10:25, alexandre.vassalotti wrote:
>>> Author: alexandre.vassalotti
>>> Date: Sun May 11 10:25:28 2008
>>> New Revision: 63042
>>>
>>> Log:
>>> Added module stub for copy_reg renaming in 3.0.
>>> Renamed copy_reg to copyreg in the standard library, to avoid
>>> spurious warnings and ease later merging to py3k branch. Public
>>> documentation remains intact.
>>>
>>> ==============================================================================
>>> --- python/trunk/Lib/copy_reg.py        (original)
>>> +++ python/trunk/Lib/copy_reg.py        Sun May 11 10:25:28 2008
>>> ...
>>>
>>> +import copyreg
>>> +sys.modules[__name__] = copyreg
>> Will this hack really work for all kinds of imports, e.g.
>> from copy_reg import pickle ?
>>
> 
> Yes, it should work for all kinds of imports. I agree that this is a
> hack, though.
> 
>> Wouldn't:
>>
>> import copyreg
>> __dict__.update(copyreg.__dict__)
>>
>> be safer ?
>>
> 
> Maybe, but unfortunately that doesn't work. The __dict__ attribute
> doesn't exist at the module top level.

Ah, right: __dict__ is only available *after* the module has been
loaded.

This works:

import copyreg
locals().update(copyreg.__dict__)

-- 
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