diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-09-14 10:31:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-14 10:31:50 (GMT) |
commit | d322abbb83eb751045246a70f39d040d13a6108b (patch) | |
tree | 40ecc91950b369af1aaaebdd677c071aeae72d53 /Modules/_io | |
parent | 66da347ef0034ad9bddc7fad112025c886249f0d (diff) | |
download | cpython-d322abbb83eb751045246a70f39d040d13a6108b.zip cpython-d322abbb83eb751045246a70f39d040d13a6108b.tar.gz cpython-d322abbb83eb751045246a70f39d040d13a6108b.tar.bz2 |
[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>
Diffstat (limited to 'Modules/_io')
-rw-r--r-- | Modules/_io/_iomodule.c | 8 | ||||
-rw-r--r-- | Modules/_io/clinic/fileio.c.h | 4 | ||||
-rw-r--r-- | Modules/_io/fileio.c | 6 | ||||
-rw-r--r-- | Modules/_io/textio.c | 6 |
4 files changed, 12 insertions, 12 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 5c2f019..49ed2cb 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -103,9 +103,9 @@ _io.open file: object mode: str = "r" buffering: int = -1 - encoding: str(accept={str, NoneType}) = NULL - errors: str(accept={str, NoneType}) = NULL - newline: str(accept={str, NoneType}) = NULL + encoding: str(accept={str, NoneType}) = None + errors: str(accept={str, NoneType}) = None + newline: str(accept={str, NoneType}) = None closefd: bool(accept={int}) = True opener: object = None @@ -233,7 +233,7 @@ static PyObject * _io_open_impl(PyObject *module, PyObject *file, const char *mode, int buffering, const char *encoding, const char *errors, const char *newline, int closefd, PyObject *opener) -/*[clinic end generated code: output=aefafc4ce2b46dc0 input=03da2940c8a65871]*/ +/*[clinic end generated code: output=aefafc4ce2b46dc0 input=7295902222e6b311]*/ { unsigned i; diff --git a/Modules/_io/clinic/fileio.c.h b/Modules/_io/clinic/fileio.c.h index 64addde..53e7067 100644 --- a/Modules/_io/clinic/fileio.c.h +++ b/Modules/_io/clinic/fileio.c.h @@ -408,7 +408,7 @@ static PyObject * _io_FileIO_truncate(fileio *self, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; - PyObject *posobj = NULL; + PyObject *posobj = Py_None; if (!_PyArg_CheckPositional("truncate", nargs, 0, 1)) { goto exit; @@ -447,4 +447,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored)) #ifndef _IO_FILEIO_TRUNCATE_METHODDEF #define _IO_FILEIO_TRUNCATE_METHODDEF #endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */ -/*[clinic end generated code: output=a7e9cca3613660fb input=a9049054013a1b77]*/ +/*[clinic end generated code: output=e7682d0a3264d284 input=a9049054013a1b77]*/ diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 7f784a3..9166c60 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -979,7 +979,7 @@ _io_FileIO_tell_impl(fileio *self) #ifdef HAVE_FTRUNCATE /*[clinic input] _io.FileIO.truncate - size as posobj: object = NULL + size as posobj: object = None / Truncate the file to at most size bytes and return the truncated size. @@ -990,7 +990,7 @@ The current file position is changed to the value of size. static PyObject * _io_FileIO_truncate_impl(fileio *self, PyObject *posobj) -/*[clinic end generated code: output=e49ca7a916c176fa input=9026af44686b7318]*/ +/*[clinic end generated code: output=e49ca7a916c176fa input=b0ac133939823875]*/ { Py_off_t pos; int ret; @@ -1002,7 +1002,7 @@ _io_FileIO_truncate_impl(fileio *self, PyObject *posobj) if (!self->writable) return err_mode("writing"); - if (posobj == Py_None || posobj == NULL) { + if (posobj == Py_None) { /* Get the current position. */ posobj = portable_lseek(self, NULL, 1); if (posobj == NULL) diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 4fe1b29..2f4a524 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -991,9 +991,9 @@ _textiowrapper_fix_encoder_state(textio *self) /*[clinic input] _io.TextIOWrapper.__init__ buffer: object - encoding: str(accept={str, NoneType}) = NULL + encoding: str(accept={str, NoneType}) = None errors: object = None - newline: str(accept={str, NoneType}) = NULL + newline: str(accept={str, NoneType}) = None line_buffering: bool(accept={int}) = False write_through: bool(accept={int}) = False @@ -1032,7 +1032,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer, const char *encoding, PyObject *errors, const char *newline, int line_buffering, int write_through) -/*[clinic end generated code: output=72267c0c01032ed2 input=1c5dd5d78bfcc675]*/ +/*[clinic end generated code: output=72267c0c01032ed2 input=77d8696d1a1f460b]*/ { PyObject *raw, *codec_info = NULL; _PyIO_State *state = NULL; |