Skip to content
Prev Previous commit
Next Next commit
Mention about change, describe tests, remove old macro
  • Loading branch information
isidentical committed Apr 20, 2020
commit 7cd943a7d65e54628fd6898e1b78087d894eb93b
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,9 @@ 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
is updated in order to prevent collision with compiler flags.
(Contributed by Batuhan Taskaya in :issue:`39562`)

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

/* These are no longer used. */
Comment thread
isidentical marked this conversation as resolved.
Outdated
#if 0
#define CO_GENERATOR_ALLOWED 0x10000
#endif
/* These values are changed in 3.9 to prevent collision with
compiler flags. See issue 39562 for more details. */
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
3 changes: 3 additions & 0 deletions Lib/test/test_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ 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
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
Comment thread
isidentical marked this conversation as resolved.
Outdated
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