[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

Alexandre Vassalotti alexandre at peadrop.com
Sun May 11 20:23:52 CEST 2008


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.

-- Alexandre


More information about the Python-checkins mailing list