Skip to content

Commit fc66ade

Browse files
author
georg.brandl
committed
Revert copy_reg -> copyreg rename.
git-svn-id: http://svn.python.org/projects/python/trunk@63493 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 78bd928 commit fc66ade

23 files changed

+83
-94
lines changed

Doc/library/copy.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ of lists by assigning a slice of the entire list, for example,
6363

6464
Classes can use the same interfaces to control copying that they use to control
6565
pickling. See the description of module :mod:`pickle` for information on these
66-
methods. The :mod:`copy` module does not use the :mod:`copyreg` registration
66+
methods. The :mod:`copy` module does not use the :mod:`copy_reg` registration
6767
module.
6868

6969
.. index::

Doc/library/copyreg.rst Doc/library/copy_reg.rst

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
:mod:`copyreg` --- Register :mod:`pickle` support functions
2-
===========================================================
1+
:mod:`copy_reg` --- Register :mod:`pickle` support functions
2+
============================================================
33

44
.. module:: copy_reg
5-
:synopsis: Old name for the copyreg module.
6-
7-
.. module:: copyreg
85
:synopsis: Register pickle support functions.
96

107
.. note::
118
The :mod:`copy_reg` module has been renamed to :mod:`copyreg` in Python 3.0.
12-
It is importable under both names in Python 2.6 and the rest of the 2.x
13-
series.
9+
The :term:`2to3` tool will automatically adapt imports when converting your
10+
sources to 3.0.
1411

1512
.. index::
1613
module: pickle
1714
module: cPickle
1815
module: copy
1916

20-
The :mod:`copyreg` module provides support for the :mod:`pickle` and
17+
The :mod:`copy_reg` module provides support for the :mod:`pickle` and
2118
:mod:`cPickle` modules. The :mod:`copy` module is likely to use this in the
2219
future as well. It provides configuration information about object constructors
2320
which are not classes. Such constructors may be factory functions or class

Doc/library/modulefinder.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Sample output (may vary depending on the architecture)::
9797

9898
Loaded modules:
9999
_types:
100-
copyreg: _inverted_registry,_slotnames,__all__
100+
copy_reg: _inverted_registry,_slotnames,__all__
101101
sre_compile: isstring,_sre,_optimize_unicode
102102
_sre:
103103
sre_constants: REPEAT_ONE,makedict,AT_END_LINE

Doc/library/persistence.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The list of modules described in this chapter is:
1919
.. toctree::
2020

2121
pickle.rst
22-
copyreg.rst
22+
copy_reg.rst
2323
shelve.rst
2424
marshal.rst
2525
anydbm.rst

Doc/library/pickle.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ not :meth:`__reduce_ex__`, the :meth:`__reduce_ex__` implementation detects this
535535
and calls :meth:`__reduce__`.
536536

537537
An alternative to implementing a :meth:`__reduce__` method on the object to be
538-
pickled, is to register the callable with the :mod:`copyreg` module. This
538+
pickled, is to register the callable with the :mod:`copy_reg` module. This
539539
module provides a way for programs to register "reduction functions" and
540540
constructors for user-defined types. Reduction functions have the same
541541
semantics and interface as the :meth:`__reduce__` method described above, except
@@ -786,7 +786,7 @@ the same process or a new process. ::
786786

787787
.. seealso::
788788

789-
Module :mod:`copyreg`
789+
Module :mod:`copy_reg`
790790
Pickle interface constructor registration for extension types.
791791

792792
Module :mod:`shelve`

Lib/copy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class instances).
4949
"""
5050

5151
import types
52-
from copyreg import dispatch_table
52+
from copy_reg import dispatch_table
5353

5454
class Error(Exception):
5555
pass

Lib/copyreg.py Lib/copy_reg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
def pickle(ob_type, pickle_function, constructor_ob=None):
1515
if type(ob_type) is _ClassType:
16-
raise TypeError("copyreg is not intended for use with classes")
16+
raise TypeError("copy_reg is not intended for use with classes")
1717

1818
if not hasattr(pickle_function, '__call__'):
1919
raise TypeError("reduction functions must be callable")

Lib/idlelib/rpc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import threading
3838
import queue
3939
import traceback
40-
import copyreg
40+
import copy_reg
4141
import types
4242
import marshal
4343

@@ -60,8 +60,8 @@ def pickle_code(co):
6060
# assert isinstance(fn, type.FunctionType)
6161
# return repr(fn)
6262

63-
copyreg.pickle(types.CodeType, pickle_code, unpickle_code)
64-
# copyreg.pickle(types.FunctionType, pickle_function, unpickle_function)
63+
copy_reg.pickle(types.CodeType, pickle_code, unpickle_code)
64+
# copy_reg.pickle(types.FunctionType, pickle_function, unpickle_function)
6565

6666
BUFSIZE = 8*1024
6767
LOCALHOST = '127.0.0.1'

Lib/lib-old/copy_reg.py

-8
This file was deleted.

Lib/os.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ def popen4(cmd, mode="t", bufsize=-1):
715715
return p.stdin, p.stdout
716716
__all__.append("popen4")
717717

718-
import copyreg as _copy_reg
718+
import copy_reg as _copy_reg
719719

720720
def _make_stat_result(tup, dict):
721721
return stat_result(tup, dict)

Lib/pickle.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Create portable serialized representations of Python objects.
22
33
See module cPickle for a (much) faster implementation.
4-
See module copyreg for a mechanism for registering custom picklers.
4+
See module copy_reg for a mechanism for registering custom picklers.
55
See module pickletools source for extensive comments.
66
77
Classes:
@@ -27,8 +27,8 @@
2727
__version__ = "$Revision$" # Code version
2828

2929
from types import *
30-
from copyreg import dispatch_table
31-
from copyreg import _extension_registry, _inverted_registry, _extension_cache
30+
from copy_reg import dispatch_table
31+
from copy_reg import _extension_registry, _inverted_registry, _extension_cache
3232
import marshal
3333
import sys
3434
import struct
@@ -295,7 +295,7 @@ def save(self, obj):
295295
self.save_global(obj)
296296
return
297297

298-
# Check copyreg.dispatch_table
298+
# Check copy_reg.dispatch_table
299299
reduce = dispatch_table.get(t)
300300
if reduce:
301301
rv = reduce(obj)

Lib/pickletools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
analysis.
137137
138138
To this end, all tests for __safe_for_unpickling__ or for
139-
copyreg.safe_constructors are removed from the unpickling code.
139+
copy_reg.safe_constructors are removed from the unpickling code.
140140
References to these variables in the descriptions below are to be seen
141141
as describing unpickling in Python 2.2 and before.
142142
"""
@@ -1525,7 +1525,7 @@ def __init__(self, name, code, arg,
15251525
BUILD opcode to apply __setstate__ to that argument.
15261526
15271527
If type(callable) is not ClassType, REDUCE complains unless the
1528-
callable has been registered with the copyreg module's
1528+
callable has been registered with the copy_reg module's
15291529
safe_constructors dict, or the callable has a magic
15301530
'__safe_for_unpickling__' attribute with a true value. I'm not sure
15311531
why it does this, but I've sure seen this complaint often enough when

Lib/re.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,12 @@ def filter(match, template=template):
278278

279279
# register myself for pickling
280280

281-
import copyreg
281+
import copy_reg
282282

283283
def _pickle(p):
284284
return _compile, (p.pattern, p.flags)
285285

286-
copyreg.pickle(_pattern_type, _pickle, _compile)
286+
copy_reg.pickle(_pattern_type, _pickle, _compile)
287287

288288
# --------------------------------------------------------------------
289289
# experimental stuff (see python-dev discussions for details)

Lib/test/pickletester.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pickle
33
import cPickle
44
import pickletools
5-
import copyreg
5+
import copy_reg
66

77
from test.test_support import TestFailed, have_unicode, TESTFN, \
88
run_with_locale
@@ -44,21 +44,21 @@ class ExtensionSaver:
4444
# there is one).
4545
def __init__(self, code):
4646
self.code = code
47-
if code in copyreg._inverted_registry:
48-
self.pair = copyreg._inverted_registry[code]
49-
copyreg.remove_extension(self.pair[0], self.pair[1], code)
47+
if code in copy_reg._inverted_registry:
48+
self.pair = copy_reg._inverted_registry[code]
49+
copy_reg.remove_extension(self.pair[0], self.pair[1], code)
5050
else:
5151
self.pair = None
5252

5353
# Restore previous registration for code.
5454
def restore(self):
5555
code = self.code
56-
curpair = copyreg._inverted_registry.get(code)
56+
curpair = copy_reg._inverted_registry.get(code)
5757
if curpair is not None:
58-
copyreg.remove_extension(curpair[0], curpair[1], code)
58+
copy_reg.remove_extension(curpair[0], curpair[1], code)
5959
pair = self.pair
6060
if pair is not None:
61-
copyreg.add_extension(pair[0], pair[1], code)
61+
copy_reg.add_extension(pair[0], pair[1], code)
6262

6363
class C:
6464
def __cmp__(self, other):
@@ -690,14 +690,14 @@ def test_newobj_generic(self):
690690
self.assertEqual(B(x), B(y), detail)
691691
self.assertEqual(x.__dict__, y.__dict__, detail)
692692

693-
# Register a type with copyreg, with extension code extcode. Pickle
693+
# Register a type with copy_reg, with extension code extcode. Pickle
694694
# an object of that type. Check that the resulting pickle uses opcode
695695
# (EXT[124]) under proto 2, and not in proto 1.
696696

697697
def produce_global_ext(self, extcode, opcode):
698698
e = ExtensionSaver(extcode)
699699
try:
700-
copyreg.add_extension(__name__, "MyList", extcode)
700+
copy_reg.add_extension(__name__, "MyList", extcode)
701701
x = MyList([1, 2, 3])
702702
x.foo = 42
703703
x.bar = "hello"

Lib/test/regrtest.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -629,15 +629,15 @@ def cleanup_test_droppings(testname, verbose):
629629

630630
def dash_R(the_module, test, indirect_test, huntrleaks):
631631
# This code is hackish and inelegant, but it seems to do the job.
632-
import copyreg, _abcoll, io
632+
import copy_reg, _abcoll, io
633633

634634
if not hasattr(sys, 'gettotalrefcount'):
635635
raise Exception("Tracking reference leaks requires a debug build "
636636
"of Python")
637637

638638
# Save current values for dash_R_cleanup() to restore.
639639
fs = warnings.filters[:]
640-
ps = copyreg.dispatch_table.copy()
640+
ps = copy_reg.dispatch_table.copy()
641641
pic = sys.path_importer_cache.copy()
642642
abcs = {}
643643
modules = _abcoll, io
@@ -677,7 +677,7 @@ def run_the_test():
677677
refrep.close()
678678

679679
def dash_R_cleanup(fs, ps, pic, abcs):
680-
import gc, copyreg
680+
import gc, copy_reg
681681
import _strptime, linecache
682682
dircache = test_support.import_module('dircache', deprecated=True)
683683
import urlparse, urllib, urllib2, mimetypes, doctest
@@ -691,8 +691,8 @@ def dash_R_cleanup(fs, ps, pic, abcs):
691691

692692
# Restore some original values.
693693
warnings.filters[:] = fs
694-
copyreg.dispatch_table.clear()
695-
copyreg.dispatch_table.update(ps)
694+
copy_reg.dispatch_table.clear()
695+
copy_reg.dispatch_table.update(ps)
696696
sys.path_importer_cache.clear()
697697
sys.path_importer_cache.update(pic)
698698

Lib/test/test___all__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_all(self):
6161
self.check_all("commands")
6262
self.check_all("compileall")
6363
self.check_all("copy")
64-
self.check_all("copyreg")
64+
self.check_all("copy_reg")
6565
self.check_all("csv")
6666
self.check_all("dbhash")
6767
self.check_all("decimal")

Lib/test/test_copy.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Unit tests for the copy module."""
22

33
import copy
4-
import copyreg
4+
import copy_reg
55

66
import unittest
77
from test import test_support
@@ -42,7 +42,7 @@ def pickle_C(obj):
4242
return (C, (obj.foo,))
4343
x = C(42)
4444
self.assertRaises(TypeError, copy.copy, x)
45-
copyreg.pickle(C, pickle_C, C)
45+
copy_reg.pickle(C, pickle_C, C)
4646
y = copy.copy(x)
4747

4848
def test_copy_reduce_ex(self):
@@ -215,7 +215,7 @@ def pickle_C(obj):
215215
return (C, (obj.foo,))
216216
x = C(42)
217217
self.assertRaises(TypeError, copy.deepcopy, x)
218-
copyreg.pickle(C, pickle_C, C)
218+
copy_reg.pickle(C, pickle_C, C)
219219
y = copy.deepcopy(x)
220220

221221
def test_deepcopy_reduce_ex(self):

0 commit comments

Comments
 (0)