bpo-35766: Change format for feature_version to (major, minor) (GH-13… · python/cpython@3ba2107 (original) (raw)

`@@ -126,7 +126,7 @@ The abstract grammar is currently defined as follows:

`

126

126

`` Apart from the node classes, the :mod:ast module defines these utility functions

``

127

127

`and classes for traversing abstract syntax trees:

`

128

128

``

129

``

`-

.. function:: parse(source, filename='', mode='exec', *, type_comments=False, feature_version=-1)

`

``

129

`+

.. function:: parse(source, filename='', mode='exec', *, type_comments=False, feature_version=None)

`

130

130

``

131

131

``` Parse the source into an AST node. Equivalent to ``compile(source,


`132`

`132`

```  filename, mode, ast.PyCF_ONLY_AST)``.

`@@ -145,11 +145,12 @@ and classes for traversing abstract syntax trees:

`

145

145

`` modified to correspond to :pep:484 "signature type comments",

``

146

146

``` e.g. (str, int) -> List[str].


`147`

`147`

``

`148`

``

``` -

Also, setting ``feature_version`` to the minor version of an

149

``

`-

earlier Python 3 version will attempt to parse using that version's

`

150

``


 grammar. For example, setting ``feature_version=4`` will allow

151

``


 the use of ``async`` and ``await`` as variable names. The lowest

152

``


 supported value is 4; the highest is ``sys.version_info[1]``.

``

148


 Also, setting ``feature_version`` to a tuple ``(major, minor)``

``

149

`+

will attempt to parse using that Python version's grammar.

`

``

150


 Currently ``major`` must equal to ``3``. For example, setting

``

151


 ``feature_version=(3, 4)`` will allow the use of ``async`` and

``

152


 ``await`` as variable names. The lowest supported version is

``

153


 ``(3, 4)``; the highest is ``sys.version_info[0:2]``.

153

154

``

154

155

` .. warning::

`

155

156

` It is possible to crash the Python interpreter with a

`