Skip to content

Commit b2fd32b

Browse files
authored
bpo-35766: compile(): rename feature_version parameter (GH-13994) (GH-14001)
Rename compile() feature_version parameter to _feature_version and convert it to a keyword-only parameter. Update also test_type_comments to pass feature_version as a tuple. (cherry picked from commit efdf6ca)
1 parent 70a4178 commit b2fd32b

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

Lib/ast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def parse(source, filename='<unknown>', mode='exec', *,
4545
feature_version = -1
4646
# Else it should be an int giving the minor version for 3.x.
4747
return compile(source, filename, mode, flags,
48-
feature_version=feature_version)
48+
_feature_version=feature_version)
4949

5050

5151
def literal_eval(node_or_string):

Lib/test/test_type_comments.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ def parse(self, source, feature_version=highest):
228228
feature_version=feature_version)
229229

230230
def parse_all(self, source, minver=lowest, maxver=highest, expected_regex=""):
231-
for feature_version in range(self.lowest, self.highest + 1):
232-
if minver <= feature_version <= maxver:
231+
for version in range(self.lowest, self.highest + 1):
232+
feature_version = (3, version)
233+
if minver <= version <= maxver:
233234
try:
234235
yield self.parse(source, feature_version)
235236
except SyntaxError as err:

Python/bltinmodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ compile as builtin_compile
696696
flags: int = 0
697697
dont_inherit: bool(accept={int}) = False
698698
optimize: int = -1
699-
feature_version: int = -1
699+
*
700+
_feature_version as feature_version: int = -1
700701
701702
Compile source into a code object that can be executed by exec() or eval().
702703
@@ -716,7 +717,7 @@ static PyObject *
716717
builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
717718
const char *mode, int flags, int dont_inherit,
718719
int optimize, int feature_version)
719-
/*[clinic end generated code: output=b0c09c84f116d3d7 input=5fcc30651a6acaa9]*/
720+
/*[clinic end generated code: output=b0c09c84f116d3d7 input=40171fb92c1d580d]*/
720721
{
721722
PyObject *source_copy;
722723
const char *str;

Python/clinic/bltinmodule.c.h

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)