From d223d5cf6d25c6f8a1da59086bd388df4c4abc4c Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Sat, 20 Jun 2020 21:31:40 +0300 Subject: [PATCH 1/3] [3.9] bpo-40939: Deprecate the PyParser_SimpleParse* functions --- Doc/c-api/veryhigh.rst | 17 +++++------------ Doc/whatsnew/3.9.rst | 5 +++++ Include/pythonrun.h | 15 +++++++-------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Doc/c-api/veryhigh.rst b/Doc/c-api/veryhigh.rst index d6aecc394c9e70..0e473f11c732b3 100644 --- a/Doc/c-api/veryhigh.rst +++ b/Doc/c-api/veryhigh.rst @@ -187,19 +187,14 @@ the same library that the Python runtime is using. :c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`. -.. c:function:: struct _node* PyParser_SimpleParseString(const char *str, int start) - - This is a simplified interface to - :c:func:`PyParser_SimpleParseStringFlagsFilename` below, leaving *filename* set - to ``NULL`` and *flags* set to ``0``. - - .. c:function:: struct _node* PyParser_SimpleParseStringFlags( const char *str, int start, int flags) This is a simplified interface to :c:func:`PyParser_SimpleParseStringFlagsFilename` below, leaving *filename* set to ``NULL``. + .. deprecated-removed:: 3.9 3.10 + .. c:function:: struct _node* PyParser_SimpleParseStringFlagsFilename( const char *str, const char *filename, int start, int flags) @@ -209,11 +204,7 @@ the same library that the Python runtime is using. many times. *filename* is decoded from the filesystem encoding (:func:`sys.getfilesystemencoding`). - -.. c:function:: struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start) - - This is a simplified interface to :c:func:`PyParser_SimpleParseFileFlags` below, - leaving *flags* set to ``0``. + .. deprecated-removed:: 3.9 3.10 .. c:function:: struct _node* PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags) @@ -221,6 +212,8 @@ the same library that the Python runtime is using. Similar to :c:func:`PyParser_SimpleParseStringFlagsFilename`, but the Python source code is read from *fp* instead of an in-memory string. + .. deprecated-removed:: 3.9 3.10 + .. c:function:: PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals) diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index 8412d1fc6dbe32..16250317b1ce7d 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -704,6 +704,11 @@ Deprecated users can leverage the Abstract Syntax Tree (AST) generation and compilation stage, using the :mod:`ast` module. +* The Public C API functions :c:func:`PyParser_SimpleParseStringFlags`, + :c:func:`PyParser_SimpleParseStringFlagsFilename` and + :c:func:`PyParser_SimpleParseFileFlags` are deprecated and will be removed + in Python 3.10 together with the old parser. + * Using :data:`NotImplemented` in a boolean context has been deprecated, as it is almost exclusively the result of incorrect rich comparator implementations. It will be made a :exc:`TypeError` in a future version diff --git a/Include/pythonrun.h b/Include/pythonrun.h index 46091e09216330..d6010053372ac1 100644 --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -72,16 +72,15 @@ PyAPI_FUNC(struct _mod *) PyParser_ASTFromFileObject( #define PyParser_SimpleParseFile(FP, S, B) \ PyParser_SimpleParseFileFlags(FP, S, B, 0) #endif -PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, - int); +Py_DEPRECATED(3.9) PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, + int, int); #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 -PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *, - const char *, - int, int); +Py_DEPRECATED(3.9) PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *, + const char *, + int, int); #endif -PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *, - int, int); - +Py_DEPRECATED(3.9) PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *, + int, int); #ifndef Py_LIMITED_API PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, PyObject *, PyCompilerFlags *); From efd55e4085b17d481fb65ed00be68693b34f06f6 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 20 Jun 2020 18:36:08 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core and Builtins/2020-06-20-18-36-05.bpo-40939.V3eiAZ.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-06-20-18-36-05.bpo-40939.V3eiAZ.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-06-20-18-36-05.bpo-40939.V3eiAZ.rst b/Misc/NEWS.d/next/Core and Builtins/2020-06-20-18-36-05.bpo-40939.V3eiAZ.rst new file mode 100644 index 00000000000000..6e60bd97bcebdd --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-06-20-18-36-05.bpo-40939.V3eiAZ.rst @@ -0,0 +1 @@ +Deprecate :c:func:`PyParser_SimpleParseStringFlags`, :c:func:`PyParser_SimpleParseStringFlagsFilename` and :c:func:`PyParser_SimpleParseFileFlags`. \ No newline at end of file From ad23355bf0d821e39c980276ee1d3eeed3edad4b Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Sun, 21 Jun 2020 03:42:20 +0300 Subject: [PATCH 3/3] Revert bad changes to docs --- Doc/c-api/veryhigh.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Doc/c-api/veryhigh.rst b/Doc/c-api/veryhigh.rst index 0e473f11c732b3..71aee140f62c1f 100644 --- a/Doc/c-api/veryhigh.rst +++ b/Doc/c-api/veryhigh.rst @@ -187,6 +187,15 @@ the same library that the Python runtime is using. :c:func:`PyMem_Malloc` or :c:func:`PyMem_Realloc`. +.. c:function:: struct _node* PyParser_SimpleParseString(const char *str, int start) + + This is a simplified interface to + :c:func:`PyParser_SimpleParseStringFlagsFilename` below, leaving *filename* set + to ``NULL`` and *flags* set to ``0``. + + .. deprecated-removed:: 3.9 3.10 + + .. c:function:: struct _node* PyParser_SimpleParseStringFlags( const char *str, int start, int flags) This is a simplified interface to @@ -207,6 +216,14 @@ the same library that the Python runtime is using. .. deprecated-removed:: 3.9 3.10 +.. c:function:: struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start) + + This is a simplified interface to :c:func:`PyParser_SimpleParseFileFlags` below, + leaving *flags* set to ``0``. + + .. deprecated-removed:: 3.9 3.10 + + .. c:function:: struct _node* PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags) Similar to :c:func:`PyParser_SimpleParseStringFlagsFilename`, but the Python