summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-09-14 12:24:05 +0300
committerGitHub <noreply@github.com>2019-09-14 12:24:05 +0300
commit279f44678c8b84a183f9eeb85e0b086228154497 (patch)
tree9cacd41975bf15ab7a94fc5ba6a2df57f8e02ee5 /Objects
parentd057b896f97e6d7447b9bf9246770c41cf205299 (diff)
downloadcpython-git-279f44678c8b84a183f9eeb85e0b086228154497.tar.gz
bpo-37206: Unrepresentable default values no longer represented as None. (GH-13933)
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytesobject.c2
-rw-r--r--Objects/clinic/bytearrayobject.c.h4
-rw-r--r--Objects/clinic/bytesobject.c.h4
-rw-r--r--Objects/clinic/dictobject.c.h6
-rw-r--r--Objects/clinic/floatobject.c.h4
-rw-r--r--Objects/clinic/memoryobject.c.h4
-rw-r--r--Objects/clinic/unicodeobject.c.h8
-rw-r--r--Objects/dictobject.c4
-rw-r--r--Objects/floatobject.c6
-rw-r--r--Objects/structseq.c4
-rw-r--r--Objects/unicodeobject.c10
11 files changed, 28 insertions, 28 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 4b2a77b4b8..7df93440a1 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -1948,7 +1948,7 @@ do_strip(PyBytesObject *self, int striptype)
Py_LOCAL_INLINE(PyObject *)
do_argstrip(PyBytesObject *self, int striptype, PyObject *bytes)
{
- if (bytes != NULL && bytes != Py_None) {
+ if (bytes != Py_None) {
return do_xstrip(self, striptype, bytes);
}
return do_strip(self, striptype);
diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h
index ad8ed7eba7..05577077a5 100644
--- a/Objects/clinic/bytearrayobject.c.h
+++ b/Objects/clinic/bytearrayobject.c.h
@@ -868,7 +868,7 @@ exit:
}
PyDoc_STRVAR(bytearray_hex__doc__,
-"hex($self, /, sep=None, bytes_per_sep=1)\n"
+"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n"
"--\n"
"\n"
"Create a str of hexadecimal numbers from a bytearray object.\n"
@@ -1011,4 +1011,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{
return bytearray_sizeof_impl(self);
}
-/*[clinic end generated code: output=09df354d3374dfb2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=508dce79cf2dffcc input=a9049054013a1b77]*/
diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h
index 7e2ce1af28..22024ab155 100644
--- a/Objects/clinic/bytesobject.c.h
+++ b/Objects/clinic/bytesobject.c.h
@@ -688,7 +688,7 @@ exit:
}
PyDoc_STRVAR(bytes_hex__doc__,
-"hex($self, /, sep=None, bytes_per_sep=1)\n"
+"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n"
"--\n"
"\n"
"Create a str of hexadecimal numbers from a bytes object.\n"
@@ -755,4 +755,4 @@ skip_optional_pos:
exit:
return return_value;
}
-/*[clinic end generated code: output=dbed3c3ff6faa382 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ca60dfccf8d51e88 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/dictobject.c.h b/Objects/clinic/dictobject.c.h
index b87244d873..7395e3bceb 100644
--- a/Objects/clinic/dictobject.c.h
+++ b/Objects/clinic/dictobject.c.h
@@ -117,10 +117,10 @@ exit:
}
PyDoc_STRVAR(dict_pop__doc__,
-"pop($self, key, default=None, /)\n"
+"pop($self, key, default=<unrepresentable>, /)\n"
"--\n"
"\n"
-"Remove specified key and return the corresponding value.\n"
+"D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n"
"\n"
"If key is not found, default is returned if given, otherwise KeyError is raised");
@@ -190,4 +190,4 @@ dict___reversed__(PyDictObject *self, PyObject *Py_UNUSED(ignored))
{
return dict___reversed___impl(self);
}
-/*[clinic end generated code: output=0fd5cafc61a51d3c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=4d98145508da8fa3 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/floatobject.c.h b/Objects/clinic/floatobject.c.h
index 6515d118e5..b684ba0ef2 100644
--- a/Objects/clinic/floatobject.c.h
+++ b/Objects/clinic/floatobject.c.h
@@ -56,7 +56,7 @@ static PyObject *
float___round__(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
- PyObject *o_ndigits = NULL;
+ PyObject *o_ndigits = Py_None;
if (!_PyArg_CheckPositional("__round__", nargs, 0, 1)) {
goto exit;
@@ -351,4 +351,4 @@ float___format__(PyObject *self, PyObject *arg)
exit:
return return_value;
}
-/*[clinic end generated code: output=cc8098eb73f1a64c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=1676433b9f04fbc9 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/memoryobject.c.h b/Objects/clinic/memoryobject.c.h
index 64fce10acb..75ac201126 100644
--- a/Objects/clinic/memoryobject.c.h
+++ b/Objects/clinic/memoryobject.c.h
@@ -3,7 +3,7 @@ preserve
[clinic start generated code]*/
PyDoc_STRVAR(memoryview_hex__doc__,
-"hex($self, /, sep=None, bytes_per_sep=1)\n"
+"hex($self, /, sep=<unrepresentable>, bytes_per_sep=1)\n"
"--\n"
"\n"
"Return the data in the buffer as a str of hexadecimal numbers.\n"
@@ -71,4 +71,4 @@ skip_optional_pos:
exit:
return return_value;
}
-/*[clinic end generated code: output=5e44e2bcf01057b5 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ee265a73f68b0077 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h
index cb350874da..c7d6edb5fd 100644
--- a/Objects/clinic/unicodeobject.c.h
+++ b/Objects/clinic/unicodeobject.c.h
@@ -630,7 +630,7 @@ static PyObject *
unicode_lstrip(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
- PyObject *chars = NULL;
+ PyObject *chars = Py_None;
if (!_PyArg_CheckPositional("lstrip", nargs, 0, 1)) {
goto exit;
@@ -664,7 +664,7 @@ static PyObject *
unicode_rstrip(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
- PyObject *chars = NULL;
+ PyObject *chars = Py_None;
if (!_PyArg_CheckPositional("rstrip", nargs, 0, 1)) {
goto exit;
@@ -1045,7 +1045,7 @@ unicode_swapcase(PyObject *self, PyObject *Py_UNUSED(ignored))
}
PyDoc_STRVAR(unicode_maketrans__doc__,
-"maketrans(x, y=None, z=None, /)\n"
+"maketrans(x, y=<unrepresentable>, z=<unrepresentable>, /)\n"
"--\n"
"\n"
"Return a translation table usable for str.translate().\n"
@@ -1232,4 +1232,4 @@ unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return unicode_sizeof_impl(self);
}
-/*[clinic end generated code: output=d9a6ee45ddd0ccfd input=a9049054013a1b77]*/
+/*[clinic end generated code: output=5e15747f78f18329 input=a9049054013a1b77]*/
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 5c0640d1df..2f24105835 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2993,14 +2993,14 @@ dict.pop
default: object = NULL
/
-Remove specified key and return the corresponding value.
+D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, default is returned if given, otherwise KeyError is raised
[clinic start generated code]*/
static PyObject *
dict_pop_impl(PyDictObject *self, PyObject *key, PyObject *default_value)
-/*[clinic end generated code: output=3abb47b89f24c21c input=016f6a000e4e633b]*/
+/*[clinic end generated code: output=3abb47b89f24c21c input=eeebec7812190348]*/
{
return _PyDict_Pop((PyObject*)self, key, default_value);
}
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 20b7f5120b..8c08866d73 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1042,7 +1042,7 @@ double_round(double x, int ndigits) {
/*[clinic input]
float.__round__
- ndigits as o_ndigits: object = NULL
+ ndigits as o_ndigits: object = None
/
Return the Integral closest to x, rounding half toward even.
@@ -1052,13 +1052,13 @@ When an argument is passed, work like built-in round(x, ndigits).
static PyObject *
float___round___impl(PyObject *self, PyObject *o_ndigits)
-/*[clinic end generated code: output=374c36aaa0f13980 input=1ca2316b510293b8]*/
+/*[clinic end generated code: output=374c36aaa0f13980 input=fc0fe25924fbc9ed]*/
{
double x, rounded;
Py_ssize_t ndigits;
x = PyFloat_AsDouble(self);
- if (o_ndigits == NULL || o_ndigits == Py_None) {
+ if (o_ndigits == Py_None) {
/* single-argument round or with None ndigits:
* round to nearest integer */
rounded = round(x);
diff --git a/Objects/structseq.c b/Objects/structseq.c
index 320bf080d7..c158afccb9 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -107,12 +107,12 @@ class structseq "PyStructSequence *" "NULL"
@classmethod
structseq.__new__ as structseq_new
sequence as arg: object
- dict: object = NULL
+ dict: object(c_default="NULL") = {}
[clinic start generated code]*/
static PyObject *
structseq_new_impl(PyTypeObject *type, PyObject *arg, PyObject *dict)
-/*[clinic end generated code: output=baa082e788b171da input=9b44810243907377]*/
+/*[clinic end generated code: output=baa082e788b171da input=90532511101aa3fb]*/
{
PyObject *ob;
PyStructSequence *res = NULL;
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index d4b2c93a84..070f795aa3 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -12522,7 +12522,7 @@ do_strip(PyObject *self, int striptype)
static PyObject *
do_argstrip(PyObject *self, int striptype, PyObject *sep)
{
- if (sep != NULL && sep != Py_None) {
+ if (sep != Py_None) {
if (PyUnicode_Check(sep))
return _PyUnicode_XStrip(self, striptype, sep);
else {
@@ -12559,7 +12559,7 @@ unicode_strip_impl(PyObject *self, PyObject *chars)
/*[clinic input]
str.lstrip as unicode_lstrip
- chars: object = NULL
+ chars: object = None
/
Return a copy of the string with leading whitespace removed.
@@ -12569,7 +12569,7 @@ If chars is given and not None, remove characters in chars instead.
static PyObject *
unicode_lstrip_impl(PyObject *self, PyObject *chars)
-/*[clinic end generated code: output=3b43683251f79ca7 input=9e56f3c45f5ff4c3]*/
+/*[clinic end generated code: output=3b43683251f79ca7 input=529f9f3834448671]*/
{
return do_argstrip(self, LEFTSTRIP, chars);
}
@@ -12578,7 +12578,7 @@ unicode_lstrip_impl(PyObject *self, PyObject *chars)
/*[clinic input]
str.rstrip as unicode_rstrip
- chars: object = NULL
+ chars: object = None
/
Return a copy of the string with trailing whitespace removed.
@@ -12588,7 +12588,7 @@ If chars is given and not None, remove characters in chars instead.
static PyObject *
unicode_rstrip_impl(PyObject *self, PyObject *chars)
-/*[clinic end generated code: output=4a59230017cc3b7a input=ac89d0219cb411ee]*/
+/*[clinic end generated code: output=4a59230017cc3b7a input=62566c627916557f]*/
{
return do_argstrip(self, RIGHTSTRIP, chars);
}