Skip to content
Prev Previous commit
Next Next commit
Apply suggestions
Co-Authored-By: Victor Stinner <vstinner@python.org>
  • Loading branch information
isidentical and vstinner committed Apr 20, 2020
commit d1094d64848f54a33199699f7c5cdea1e91bee67
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ Changes in the Python API
in the object itself.
(Contributed by Serhiy Storchaka in :issue:`40257`.)

* The constant values of future flags in the :mod:`future` module
* The constant values of future flags in the :mod:`__future__` module
is updated in order to prevent collision with compiler flags.
(Contributed by Batuhan Taskaya in :issue:`39562`)

Expand Down
4 changes: 2 additions & 2 deletions Include/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ typedef struct {
#define CO_ASYNC_GENERATOR 0x0200

/* These are no longer used. */
Comment thread
isidentical marked this conversation as resolved.
Outdated
/* These values are changed in 3.9 to prevent collision with
compiler flags. See issue 39562 for more details. */
/* bpo-39562: These constant values are changed in Python 3.9
to prevent collision with compiler flags. */
Comment thread
isidentical marked this conversation as resolved.
Outdated
#define CO_FUTURE_DIVISION 0x20000
Comment thread
isidentical marked this conversation as resolved.
Outdated
#define CO_FUTURE_ABSOLUTE_IMPORT 0x40000 /* do absolute imports by default */
#define CO_FUTURE_WITH_STATEMENT 0x80000
Expand Down
7 changes: 4 additions & 3 deletions Lib/test/test_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ def test_badfuture10(self):
self.check_syntax_error(cm.exception, "badsyntax_future10", 3)

def test_ensure_flags_dont_clash(self):
Comment thread
isidentical marked this conversation as resolved.
Outdated
# test that future flags and compiler flags doesn't clash
# obtain future flags (CO_****) from future module
# bpo-39562: test that future flags and compiler flags doesn't clash

# obtain future flags (CO_***) from the __future__ module
Comment thread
isidentical marked this conversation as resolved.
Outdated
flags = [
getattr(__future__, future).compiler_flag
for future in __future__.all_feature_names
]
# obtain some of the exported compiler flags (PyCF_****) from ast
# obtain some of the exported compiler flags (PyCF_***) from the ast module
flags.extend(
getattr(ast, flag) for flag in dir(ast) if flag.startswith("PyCF_")
)
Comment thread
isidentical marked this conversation as resolved.
Outdated
Expand Down