summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-09-02 10:58:00 (GMT)
committerGitHub <noreply@github.com>2021-09-02 10:58:00 (GMT)
commit19ba2122ac7313ac29207360cfa864a275b9489e (patch)
treeab34611e2b6158889cabec93f76f40c71b6ea470 /Modules
parenta8066087054417885db0a2dbdce2ddb2ac498247 (diff)
downloadcpython-19ba2122ac7313ac29207360cfa864a275b9489e.zip
cpython-19ba2122ac7313ac29207360cfa864a275b9489e.tar.gz
cpython-19ba2122ac7313ac29207360cfa864a275b9489e.tar.bz2
bpo-37330: open() no longer accept 'U' in file mode (GH-28118)
open(), io.open(), codecs.open() and fileinput.FileInput no longer accept "U" ("universal newline") in the file mode. This flag was deprecated since Python 3.3.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_io/_iomodule.c25
-rw-r--r--Modules/_io/clinic/_iomodule.c.h7
2 files changed, 3 insertions, 29 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index 170dea4..b4743fb 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -138,7 +138,6 @@ Character Meaning
'b' binary mode
't' text mode (default)
'+' open a disk file for updating (reading and writing)
-'U' universal newline mode (deprecated)
========= ===============================================================
The default mode is 'rt' (open for reading text). For binary random
@@ -154,10 +153,6 @@ bytes objects without any decoding. In text mode (the default, or when
returned as strings, the bytes having been first decoded using a
platform-dependent encoding or using the specified encoding if given.
-'U' mode is deprecated and will raise an exception in future versions
-of Python. It has no effect in Python 3. Use newline to control
-universal newlines mode.
-
buffering is an optional integer used to set the buffering policy.
Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
line buffering (only usable in text mode), and an integer > 1 to indicate
@@ -233,12 +228,12 @@ 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=7295902222e6b311]*/
+/*[clinic end generated code: output=aefafc4ce2b46dc0 input=1543f4511d2356a5]*/
{
unsigned i;
int creating = 0, reading = 0, writing = 0, appending = 0, updating = 0;
- int text = 0, binary = 0, universal = 0;
+ int text = 0, binary = 0;
char rawmode[6], *m;
int line_buffering, is_number;
@@ -296,10 +291,6 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
case 'b':
binary = 1;
break;
- case 'U':
- universal = 1;
- reading = 1;
- break;
default:
goto invalid_mode;
}
@@ -322,18 +313,6 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
*m = '\0';
/* Parameters validation */
- if (universal) {
- if (creating || writing || appending || updating) {
- PyErr_SetString(PyExc_ValueError,
- "mode U cannot be combined with 'x', 'w', 'a', or '+'");
- goto error;
- }
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "'U' mode is deprecated", 1) < 0)
- goto error;
- reading = 1;
- }
-
if (text && binary) {
PyErr_SetString(PyExc_ValueError,
"can't have text and binary mode at once");
diff --git a/Modules/_io/clinic/_iomodule.c.h b/Modules/_io/clinic/_iomodule.c.h
index 91c55b1..d5fb176 100644
--- a/Modules/_io/clinic/_iomodule.c.h
+++ b/Modules/_io/clinic/_iomodule.c.h
@@ -36,7 +36,6 @@ PyDoc_STRVAR(_io_open__doc__,
"\'b\' binary mode\n"
"\'t\' text mode (default)\n"
"\'+\' open a disk file for updating (reading and writing)\n"
-"\'U\' universal newline mode (deprecated)\n"
"========= ===============================================================\n"
"\n"
"The default mode is \'rt\' (open for reading text). For binary random\n"
@@ -52,10 +51,6 @@ PyDoc_STRVAR(_io_open__doc__,
"returned as strings, the bytes having been first decoded using a\n"
"platform-dependent encoding or using the specified encoding if given.\n"
"\n"
-"\'U\' mode is deprecated and will raise an exception in future versions\n"
-"of Python. It has no effect in Python 3. Use newline to control\n"
-"universal newlines mode.\n"
-"\n"
"buffering is an optional integer used to set the buffering policy.\n"
"Pass 0 to switch buffering off (only allowed in binary mode), 1 to select\n"
"line buffering (only usable in text mode), and an integer > 1 to indicate\n"
@@ -359,4 +354,4 @@ _io_open_code(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec
exit:
return return_value;
}
-/*[clinic end generated code: output=06e055d1d80b835d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6ea315343f6a94ba input=a9049054013a1b77]*/