Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a6b45cc3
Commit
a6b45cc3
authored
Dec 07, 2004
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eliminate the deprecated option to return None instead of a tuple of arguments in __reduce__().
parent
84667c06
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
33 deletions
+16
-33
Doc/lib/libpickle.tex
Doc/lib/libpickle.tex
+2
-6
Lib/pickle.py
Lib/pickle.py
+2
-16
Misc/NEWS
Misc/NEWS
+6
-0
Modules/cPickle.c
Modules/cPickle.c
+6
-11
No files found.
Doc/lib/libpickle.tex
View file @
a6b45cc3
...
...
@@ -515,12 +515,8 @@ Otherwise, an \exception{UnpicklingError} will be raised in the
unpickling environment. Note that as usual, the callable itself is
pickled by name.
\item
A tuple of arguments for the callable object, or
\code
{
None
}
.
\deprecated
{
2.3
}{
If this item is
\code
{
None
}
, then instead of calling
the callable directly, its
\method
{__
basicnew
__
()
}
method is called
without arguments; this method should also return the unpickled
object. Providing
\code
{
None
}
is deprecated, however; return a
tuple of arguments instead.
}
\item
A tuple of arguments for the callable object.
\versionchanged
[Formerly, this argument could also be \code{None}]
{
2.5
}
\item
Optionally, the object's state, which will be passed to
the object's
\method
{__
setstate
__
()
}
method as described in
...
...
Lib/pickle.py
View file @
a6b45cc3
...
...
@@ -33,7 +33,6 @@ import marshal
import
sys
import
struct
import
re
import
warnings
__all__
=
[
"PickleError"
,
"PicklingError"
,
"UnpicklingError"
,
"Pickler"
,
"Unpickler"
,
"dump"
,
"dumps"
,
"load"
,
"loads"
]
...
...
@@ -349,14 +348,7 @@ class Pickler:
# Assert that args is a tuple or None
if
not
isinstance
(
args
,
TupleType
):
if
args
is
None
:
# A hack for Jim Fulton's ExtensionClass, now deprecated.
# See load_reduce()
warnings
.
warn
(
"__basicnew__ special case is deprecated"
,
DeprecationWarning
)
else
:
raise
PicklingError
(
"args from reduce() should be a tuple"
)
raise
PicklingError
(
"args from reduce() should be a tuple"
)
# Assert that func is callable
if
not
callable
(
func
):
...
...
@@ -1138,13 +1130,7 @@ class Unpickler:
stack
=
self
.
stack
args
=
stack
.
pop
()
func
=
stack
[
-
1
]
if
args
is
None
:
# A hack for Jim Fulton's ExtensionClass, now deprecated
warnings
.
warn
(
"__basicnew__ special case is deprecated"
,
DeprecationWarning
)
value
=
func
.
__basicnew__
()
else
:
value
=
func
(
*
args
)
value
=
func
(
*
args
)
stack
[
-
1
]
=
value
dispatch
[
REDUCE
]
=
load_reduce
...
...
Misc/NEWS
View file @
a6b45cc3
...
...
@@ -17,6 +17,9 @@ Core and builtins
Extension Modules
-----------------
- the cPickle module no longer accepts the deprecated None option in the
args tuple returned by __reduce__().
- itertools.islice() now accepts None for the start and step arguments.
This allows islice() to work more readily with slices:
islice(s.start, s.stop, s.step)
...
...
@@ -25,6 +28,9 @@ Extension Modules
Library
-------
- the pickle module no longer accepts the deprecated None option in the
args tuple returned by __reduce__().
- optparse now optionally imports gettext. This allows its use in setup.py.
- the deprecated tzparse module was removed.
...
...
Modules/cPickle.c
View file @
a6b45cc3
...
...
@@ -2143,6 +2143,12 @@ save_reduce(Picklerobject *self, PyObject *args, PyObject *ob)
&
dictitems
))
return
-
1
;
if
(
!
PyTuple_Check
(
argtup
))
{
PyErr_SetString
(
PicklingError
,
"args from reduce() should be a tuple"
);
return
-
1
;
}
if
(
state
==
Py_None
)
state
=
NULL
;
if
(
listitems
==
Py_None
)
...
...
@@ -3616,17 +3622,6 @@ Instance_New(PyObject *cls, PyObject *args)
else
goto
err
;
}
if
(
args
==
Py_None
)
{
/* Special case, call cls.__basicnew__() */
PyObject
*
basicnew
;
basicnew
=
PyObject_GetAttr
(
cls
,
__basicnew___str
);
if
(
!
basicnew
)
return
NULL
;
r
=
PyObject_CallObject
(
basicnew
,
NULL
);
Py_DECREF
(
basicnew
);
if
(
r
)
return
r
;
}
if
((
r
=
PyObject_CallObject
(
cls
,
args
)))
return
r
;
err:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment