diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2020-05-01 14:18:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-01 14:18:27 (GMT) |
commit | 5055c274c6e4f2bb8025910dedf0ff89f4bdd170 (patch) | |
tree | 0e8ec7fff9958bd3afcabb38f968fd26eba9dd5f /Lib/test | |
parent | 95e208dce505c542b8e4f8f42c57e6d4793b6895 (diff) | |
download | cpython-5055c274c6e4f2bb8025910dedf0ff89f4bdd170.zip cpython-5055c274c6e4f2bb8025910dedf0ff89f4bdd170.tar.gz cpython-5055c274c6e4f2bb8025910dedf0ff89f4bdd170.tar.bz2 |
[3.8] bpo-39562: Prevent collision of future and compiler flags (GH-19230) (GH-19835)
The constant values of future flags in the __future__ module
is updated in order to prevent collision with compiler flags.
Previously PyCF_ALLOW_TOP_LEVEL_AWAIT was clashing
with CO_FUTURE_DIVISION..
(cherry picked from commit 4454057269b995341b04d13f0bf97f96080f27d0)
Co-authored-by: Batuhan Taşkaya <batuhanosmantaskaya@gmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_future.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py index d83c47e..ea13533 100644 --- a/Lib/test/test_future.py +++ b/Lib/test/test_future.py @@ -1,5 +1,7 @@ # Test various flavors of legal and illegal future statements +import __future__ +import ast import unittest from test import support from textwrap import dedent @@ -74,6 +76,21 @@ class FutureTest(unittest.TestCase): from test import badsyntax_future10 self.check_syntax_error(cm.exception, "badsyntax_future10", 3) + def test_ensure_flags_dont_clash(self): + # bpo-39562: test that future flags and compiler flags doesn't clash + + # obtain future flags (CO_FUTURE_***) from the __future__ module + flags = { + f"CO_FUTURE_{future.upper()}": getattr(__future__, future).compiler_flag + for future in __future__.all_feature_names + } + # obtain some of the exported compiler flags (PyCF_***) from the ast module + flags.update({ + flag: getattr(ast, flag) + for flag in dir(ast) if flag.startswith("PyCF_") + }) + self.assertCountEqual(set(flags.values()), flags.values()) + def test_parserhack(self): # test that the parser.c::future_hack function works as expected # Note: although this test must pass, it's not testing the original |