[3.8] bpo-37206: Unrepresentable default values no longer represented as None. (GH-13933) (GH-16141)
In ArgumentClinic, value "NULL" should now be used only for unrepresentable default values
(like in the optional third parameter of getattr). "None" should be used if None is accepted
as argument and passing None has the same effect as not passing the argument at all.
(cherry picked from commit 279f44678c8b84a183f9eeb85e0b086228154497)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index fa2ef7d..8ee7d8e 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -1142,7 +1142,7 @@
{
long proto;
- if (protocol == NULL || protocol == Py_None) {
+ if (protocol == Py_None) {
proto = DEFAULT_PROTOCOL;
}
else {
@@ -4640,9 +4640,9 @@
_pickle.Pickler.__init__
file: object
- protocol: object = NULL
+ protocol: object = None
fix_imports: bool = True
- buffer_callback: object = NULL
+ buffer_callback: object = None
This takes a binary file for writing a pickle data stream.
@@ -4680,7 +4680,7 @@
_pickle_Pickler___init___impl(PicklerObject *self, PyObject *file,
PyObject *protocol, int fix_imports,
PyObject *buffer_callback)
-/*[clinic end generated code: output=0abedc50590d259b input=9a43a1c50ab91652]*/
+/*[clinic end generated code: output=0abedc50590d259b input=bb886e00443a7811]*/
{
_Py_IDENTIFIER(persistent_id);
_Py_IDENTIFIER(dispatch_table);
@@ -7202,7 +7202,7 @@
fix_imports: bool = True
encoding: str = 'ASCII'
errors: str = 'strict'
- buffers: object = NULL
+ buffers: object(c_default="NULL") = ()
This takes a binary file for reading a pickle data stream.
@@ -7230,7 +7230,7 @@
_pickle_Unpickler___init___impl(UnpicklerObject *self, PyObject *file,
int fix_imports, const char *encoding,
const char *errors, PyObject *buffers)
-/*[clinic end generated code: output=09f0192649ea3f85 input=da4b62d9edb68700]*/
+/*[clinic end generated code: output=09f0192649ea3f85 input=ca4c1faea9553121]*/
{
_Py_IDENTIFIER(persistent_load);
@@ -7622,10 +7622,10 @@
obj: object
file: object
- protocol: object = NULL
+ protocol: object = None
*
fix_imports: bool = True
- buffer_callback: object = NULL
+ buffer_callback: object = None
Write a pickled representation of obj to the open file object file.
@@ -7660,7 +7660,7 @@
_pickle_dump_impl(PyObject *module, PyObject *obj, PyObject *file,
PyObject *protocol, int fix_imports,
PyObject *buffer_callback)
-/*[clinic end generated code: output=706186dba996490c input=2f035f02cc0f9547]*/
+/*[clinic end generated code: output=706186dba996490c input=cfdcaf573ed6e46c]*/
{
PicklerObject *pickler = _Pickler_New();
@@ -7695,10 +7695,10 @@
_pickle.dumps
obj: object
- protocol: object = NULL
+ protocol: object = None
*
fix_imports: bool = True
- buffer_callback: object = NULL
+ buffer_callback: object = None
Return the pickled representation of the object as a bytes object.
@@ -7724,7 +7724,7 @@
static PyObject *
_pickle_dumps_impl(PyObject *module, PyObject *obj, PyObject *protocol,
int fix_imports, PyObject *buffer_callback)
-/*[clinic end generated code: output=fbab0093a5580fdf input=001f167df711b9f1]*/
+/*[clinic end generated code: output=fbab0093a5580fdf input=9f334d535ff7194f]*/
{
PyObject *result;
PicklerObject *pickler = _Pickler_New();
@@ -7759,7 +7759,7 @@
fix_imports: bool = True
encoding: str = 'ASCII'
errors: str = 'strict'
- buffers: object = NULL
+ buffers: object(c_default="NULL") = ()
Read and return an object from the pickle data stored in a file.
@@ -7790,7 +7790,7 @@
_pickle_load_impl(PyObject *module, PyObject *file, int fix_imports,
const char *encoding, const char *errors,
PyObject *buffers)
-/*[clinic end generated code: output=250452d141c23e76 input=29fae982fe778156]*/
+/*[clinic end generated code: output=250452d141c23e76 input=46c7c31c92f4f371]*/
{
PyObject *result;
UnpicklerObject *unpickler = _Unpickler_New();
@@ -7827,7 +7827,7 @@
fix_imports: bool = True
encoding: str = 'ASCII'
errors: str = 'strict'
- buffers: object = NULL
+ buffers: object(c_default="NULL") = ()
Read and return an object from the given pickle data.
@@ -7849,7 +7849,7 @@
_pickle_loads_impl(PyObject *module, PyObject *data, int fix_imports,
const char *encoding, const char *errors,
PyObject *buffers)
-/*[clinic end generated code: output=82ac1e6b588e6d02 input=c6004393f8276867]*/
+/*[clinic end generated code: output=82ac1e6b588e6d02 input=9c2ab6a0960185ea]*/
{
PyObject *result;
UnpicklerObject *unpickler = _Unpickler_New();