[issue19209] Remove import copyreg from os module

STINNER Victor report at bugs.python.org
Thu Oct 10 10:09:22 CEST 2013


STINNER Victor added the comment:

> Can't we modify the qualified name instead?

Attached os_stat_statvfs_pickle.patch implements this idea. IMO it's much simpler because it removes completly the need of the copyreg module.

Example with the patch on Linux:

$ ./python
Python 3.4.0a3+ (default:63a1ee94b3ed+, Oct 10 2013, 10:03:45) 
>>> import os, pickletools, pickle
>>> s=os.stat('.')
>>> pickletools.dis(pickle.dumps(s))
    0: \x80 PROTO      3
    2: c    GLOBAL     'os stat_result'
...
>>> pickle.loads(pickle.dumps(s))
os.stat_result(st_mode=16893, st_ino=19792207, st_dev=64772, st_nlink=17, st_uid=1000, st_gid=1000, st_size=28672, st_atime=1381392226, st_mtime=1381392226, st_ctime=1381392226)
>>> 
>>> v=os.statvfs('.')
>>> pickletools.dis(pickle.dumps(v))
    0: \x80 PROTO      3
    2: c    GLOBAL     'os statvfs_result'
...
>>> pickle.loads(pickle.dumps(v))
os.statvfs_result(f_bsize=4096, f_frsize=4096, f_blocks=125958458, f_bfree=124095595, f_bavail=117695595, f_files=32006144, f_ffree=31792079, f_favail=31792079, f_flag=4096, f_namemax=255)

----------
Added file: http://bugs.python.org/file32026/os_stat_statvfs_pickle.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19209>
_______________________________________


More information about the Python-bugs-list mailing list