Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
36b718d
Count leading zero bits in one CPU tick
hnarkaytis Apr 21, 2020
5414a2f
Count leading zero bits in one CPU tick
hnarkaytis Apr 21, 2020
9b30a64
Merge branch 'count_leading_zeros' of github.com:hnarkaytis/cpython i…
hnarkaytis Apr 21, 2020
7e982dc
Add support for _MSC_
hnarkaytis Apr 21, 2020
debeb02
Workaround _MCVC_ support
hnarkaytis Apr 21, 2020
9c82ea7
bpo-34037: Add Python API whatsnew for loop.shutdown_default_executor…
aeros Apr 21, 2020
d3a8d61
Small improvements to the recipes and examples. (GH-19635)
rhettinger Apr 21, 2020
75bedbe
bpo-40327: Improve atomicity, speed, and memory efficiency of the ite…
rhettinger Apr 21, 2020
783a673
bpo-40164: Update macOS installer builds to use OpenSSL 1.1.1g. (GH-1…
ned-deily Apr 22, 2020
939e4c1
Workaround _MCVC_ inability to handle macro
hnarkaytis Apr 22, 2020
3a69f3c
bpo-38439: Add 256px IDLE icon (GH-17473)
hroncok Apr 22, 2020
b310700
bpo-38360: macOS: support alternate form of -isysroot flag (GH-16480)
jmroot Apr 22, 2020
bcc136b
bpo-38329: python.org macOS installers now update Current symlink (GH…
ned-deily Apr 22, 2020
9e2e2f3
Count leading zero bits with single CPU instruction
hnarkaytis Apr 22, 2020
22141ec
Replace __builtin_clz with __builtin_clzl
hnarkaytis Apr 22, 2020
886a15b
Change preprocessor check on ifdef MS_WINDOWS
hnarkaytis Apr 22, 2020
bd95e34
Add debug preprocessor check on ifdef MS_WINDOWS
hnarkaytis Apr 22, 2020
543e481
Fix typo and argument type
hnarkaytis Apr 22, 2020
9bee32b
bpo-40138: Fix Windows os.waitpid() for large exit code (GH-19637)
vstinner Apr 22, 2020
9b49893
bpo-40214: Fix ctypes WinDLL test with insecure flags (GH-19652)
zooba Apr 22, 2020
4454057
bpo-39562: Prevent collision of future and compiler flags (GH-19230)
isidentical Apr 22, 2020
39652cd
bpo-40260: Remove unnecessary newline in compile() call (GH-19641)
asottile Apr 22, 2020
a81849b
bpo-39939: Add str.removeprefix and str.removesuffix (GH-18939)
sweeneyde Apr 22, 2020
c5fc156
bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)
pablogsal Apr 22, 2020
3f8a58b
PEP 617: Only run the CI with the new parser (GH-19664)
pablogsal Apr 22, 2020
458004b
bpo-40334: Fix errors in parse_string.c with old compilers (GH-19666)
pablogsal Apr 22, 2020
ce0eacb
Add @pablogsal as code owner for pegen-related files (GH-19665)
pablogsal Apr 22, 2020
a25f3c4
bpo-40334: Fix builds outside the source directory and regenerate aut…
pablogsal Apr 23, 2020
1def775
bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)
vstinner Apr 23, 2020
0b7829e
Compile extensions in test_peg_generator with C99 (GH-19668)
pablogsal Apr 23, 2020
ee40e4b
bpo-40334: Don't downcast from Py_ssize_t to int (GH-19671)
pablogsal Apr 23, 2020
1df5a9e
bpo-40334: Fix build errors and warnings in test_peg_generator (GH-19…
pablogsal Apr 23, 2020
8d1cbff
bpo-40334: Suppress all output in test_peg_generator (GH-19675)
lysnikolaou Apr 23, 2020
1221135
gdbinit: Use proper define syntax (GH-19557)
The-Compiler Apr 23, 2020
9e6a131
bpo-40370: Use the same compile and link args as the interpreter used…
pablogsal Apr 23, 2020
ebebb64
bpo-40334: Improve various PEG-Parser related stuff (GH-19669)
lysnikolaou Apr 23, 2020
02e4484
Update ga_new to use _PyArg_CheckPositional and _PyArg_NoKwnames (GH-…
corona10 Apr 23, 2020
d663d34
bpo-39983: Add test.support.print_warning() (GH-19683)
vstinner Apr 23, 2020
40ded94
bpo-40336: Refactor typing._SpecialForm (GH-19620)
serhiy-storchaka Apr 23, 2020
bc28805
bpo-40334: Use old compiler when compile mode is func_type (GH-19692)
gvanrossum Apr 23, 2020
3e89251
Fix broken mkdir -p call in regen-pegen (#19695)
gvanrossum Apr 23, 2020
50f28de
bpo-40334: Allow to run make regen-pegen without distutils (GH-19684)
pablogsal Apr 23, 2020
9f27dd3
Use Py_ssize_t instead of ssize_t (GH-19685)
pablogsal Apr 24, 2020
2510494
bpo-40048: Fix _PyCode_InitOpcache() error path (GH-19691)
vstinner Apr 24, 2020
4cc4d60
Expand the implementation comments (GH-19699)
rhettinger Apr 24, 2020
162c567
bpo-38061: os.closerange() uses closefrom() on FreeBSD (GH-19696)
vstinner Apr 24, 2020
e6f8abd
bpo-38061: subprocess uses closefrom() on FreeBSD (GH-19697)
vstinner Apr 24, 2020
24ffe70
bpo-40334: Rewrite test_c_parser to avoid memory leaks (GH-19694)
lysnikolaou Apr 24, 2020
503de71
bpo-40360: Deprecate lib2to3 module in light of PEP 617 (GH-19663)
carljm Apr 24, 2020
5aafa54
bpo-40340: Separate examples more clearly in the programming FAQ (GH-…
caje731 Apr 24, 2020
0e80b56
bpo-40334: Add What's New sections for PEP 617 and PEP 585 (GH-19704)
gvanrossum Apr 25, 2020
f828077
closes bpo-40385: Remove Tools/scripts/checkpyc.py (GH-19709)
ammaraskar Apr 25, 2020
d4f3923
bpo-40279: Add some error-handling to the module initialisation docs …
caje731 Apr 25, 2020
3c8a5b4
bpo-40275: Avoid importing asyncio in test.support (GH-19600)
serhiy-storchaka Apr 25, 2020
1699491
bpo-40275: Avoid importing socket in test.support (GH-19603)
serhiy-storchaka Apr 25, 2020
515fce4
bpo-40275: Avoid importing logging in test.support (GH-19601)
serhiy-storchaka Apr 25, 2020
ef33712
Fix typo in object.__format__ docs (GH-19504)
hroskes Apr 26, 2020
cfaf4c0
Fix typo in Lib/typing.py (GH-19717)
nfishe Apr 26, 2020
68b352a
bpo-40396: Support GenericAlias in the typing functions. (GH-19718)
serhiy-storchaka Apr 26, 2020
88499f1
bpo-40387: Improve queue join() example. (GH-19724)
rhettinger Apr 27, 2020
a494caa
bpo-40401: Remove duplicate pyhash.h include from pythoncore.vcxproj …
ammaraskar Apr 27, 2020
b54e46c
bpo-38387: Formally document PyDoc_STRVAR and PyDoc_STR macros (GH-16…
bsolomon1124 Apr 27, 2020
caf1aad
bpo-40348: Fix typos in the programming FAQ (GH-19729)
ZackerySpytz Apr 27, 2020
6292be7
bpo-40398: Fix typing.get_args() for special generic aliases. (GH-19720)
serhiy-storchaka Apr 27, 2020
4044c84
Add files in tests/test_peg_generator to the install target lists (GH…
pablogsal Apr 27, 2020
0169d30
bpo-40217: Ensure Py_VISIT(Py_TYPE(self)) is always called for PyType…
pablogsal Apr 27, 2020
91a5ae1
bpo-40217: Clean code in PyType_FromSpec_Alloc and add NEWS entry (GH…
pablogsal Apr 27, 2020
c5c4281
bpo-40375: Implement imaplib.IMAP4.unselect (GH-19712)
corona10 Apr 27, 2020
9adccc1
bpo-30966: Add multiprocessing.SimpleQueue.close() (GH-19735)
vstinner Apr 27, 2020
2b74c83
bpo-40334: Support CO_FUTURE_BARRY_AS_BDFL in the new parser (GH-19721)
pablogsal Apr 27, 2020
b94dbd7
bpo-40334: Support PyPARSE_DONT_IMPLY_DEDENT in the new parser (GH-19…
pablogsal Apr 27, 2020
1a27501
bpo-30966: concurrent.futures.Process.shutdown() closes queue (GH-19738)
vstinner Apr 27, 2020
5d1f32d
bpo-39995: Split test_concurrent_futures.test_crash() into sub-tests …
vstinner Apr 27, 2020
bc1c8af
Python 3.9.0a6
ambv Apr 27, 2020
d55133f
bpo-40334: Catch E_EOF error, when the tokenizer returns ERRORTOKEN (…
lysnikolaou Apr 28, 2020
3d53d87
bpo-40334: Don't skip test_parser:test_trigget_memory_error (GH-19744)
lysnikolaou Apr 28, 2020
5b9f498
bpo-40334: Refactor peg_generator to receive a Tokens file when build…
pablogsal Apr 28, 2020
d66685a
Merge tag 'v3.9.0a6'
ambv Apr 28, 2020
5da3526
Post 3.9.0a6
ambv Apr 28, 2020
7c59d7c
bpo-40421: Add pyframe.h header file (GH-19755)
vstinner Apr 28, 2020
b8f704d
bpo-40421: Add Include/cpython/code.h header file (GH-19756)
vstinner Apr 28, 2020
a42ca74
bpo-40421: Add PyFrame_GetCode() function (GH-19757)
vstinner Apr 28, 2020
d9a43e2
bpo-40025: Require _generate_next_value_ to be defined before members…
abbyonstott Apr 28, 2020
521c8d6
bpo-39966: Revert "bpo-25597: Ensure wraps' return value is used for …
tirkarthi Apr 28, 2020
6d86a23
bpo-40429: PyFrame_GetCode() result cannot be NULL (GH-19772)
vstinner Apr 28, 2020
5e8c691
bpo-32604: Add support for a "default" arg in channel_recv(). (GH-19770)
ericsnowcurrently Apr 28, 2020
8852ad4
bpo-40429: PyFrame_GetCode() now returns a strong reference (GH-19773)
vstinner Apr 28, 2020
49f70db
bpo-40431: Fix syntax typo in turtledemo (GH-19777)
hroncok Apr 29, 2020
f7bbf58
bpo-38880: List interpreters associated with a channel end (GH-17323)
LewisGaul Apr 29, 2020
cc0dc7e
bpo-40429: Refactor super_init() (GH-19776)
vstinner Apr 29, 2020
ae00a5a
bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769)
vstinner Apr 29, 2020
37af21b
bpo-40334: Fix shifting of nested f-strings in the new parser (GH-19771)
lysnikolaou Apr 29, 2020
4386b90
bpo-40429: PyThreadState_GetFrame() returns a strong ref (GH-19781)
vstinner Apr 29, 2020
2208134
bpo-40334: Explicitly cast to int in pegen.c to fix a compiler warnin…
pablogsal Apr 29, 2020
66abe98
bpo-40275: Move requires_hashdigest() to test.support.hashlib_helper …
shihai1991 Apr 29, 2020
7036477
bpo-40421: Add PyFrame_GetBack() function (GH-19765)
vstinner Apr 29, 2020
a4dfe8e
bpo-39995: Fix concurrent.futures _ThreadWakeup (GH-19760)
vstinner Apr 29, 2020
6d65087
bpo-40334: Disallow invalid single statements in the new parser (GH-1…
lysnikolaou Apr 29, 2020
bb4a585
bpo-40428: Remove references to Py*_ClearFreeList in the docs (GH-19783)
ZackerySpytz Apr 29, 2020
8f36fda
Count leading zero bits in one CPU tick
hnarkaytis Apr 21, 2020
64ecf0d
Rebase to master
hnarkaytis Apr 29, 2020
2908911
Cleanup merge conflict artifacts
hnarkaytis Apr 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bpo-39562: Prevent collision of future and compiler flags (GH-19230)
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.
  • Loading branch information
isidentical authored Apr 22, 2020
commit 4454057269b995341b04d13f0bf97f96080f27d0
4 changes: 4 additions & 0 deletions Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,10 @@ Changes in the Python API
inherit from it should have this method defined.
(Contributed by Kyle Stanley in :issue:`34037`.)

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

CPython bytecode changes
------------------------
Expand Down
26 changes: 13 additions & 13 deletions Include/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ typedef struct {
#define CO_ITERABLE_COROUTINE 0x0100
#define CO_ASYNC_GENERATOR 0x0200

/* These are no longer used. */
#if 0
#define CO_GENERATOR_ALLOWED 0x1000
#endif
#define CO_FUTURE_DIVISION 0x2000
#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */
#define CO_FUTURE_WITH_STATEMENT 0x8000
#define CO_FUTURE_PRINT_FUNCTION 0x10000
#define CO_FUTURE_UNICODE_LITERALS 0x20000

#define CO_FUTURE_BARRY_AS_BDFL 0x40000
#define CO_FUTURE_GENERATOR_STOP 0x80000
#define CO_FUTURE_ANNOTATIONS 0x100000
/* bpo-39562: These constant values are changed in Python 3.9
to prevent collision with compiler flags. CO_FUTURE_ and PyCF_
constants must be kept unique. PyCF_ constants can use bits from
0x0100 to 0x10000. CO_FUTURE_ constants use bits starting at 0x20000. */
#define CO_FUTURE_DIVISION 0x20000
#define CO_FUTURE_ABSOLUTE_IMPORT 0x40000 /* do absolute imports by default */
#define CO_FUTURE_WITH_STATEMENT 0x80000
#define CO_FUTURE_PRINT_FUNCTION 0x100000
#define CO_FUTURE_UNICODE_LITERALS 0x200000

#define CO_FUTURE_BARRY_AS_BDFL 0x400000
#define CO_FUTURE_GENERATOR_STOP 0x800000
#define CO_FUTURE_ANNOTATIONS 0x1000000

/* This value is found in the co_cell2arg array when the associated cell
variable does not correspond to an argument. */
Expand Down
6 changes: 6 additions & 0 deletions Include/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \
CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS)
#define PyCF_MASK_OBSOLETE (CO_NESTED)

/* bpo-39562: CO_FUTURE_ and PyCF_ constants must be kept unique.
PyCF_ constants can use bits from 0x0100 to 0x10000.
CO_FUTURE_ constants use bits starting at 0x20000. */
#define PyCF_SOURCE_IS_UTF8 0x0100
#define PyCF_DONT_IMPLY_DEDENT 0x0200
#define PyCF_ONLY_AST 0x0400
#define PyCF_IGNORE_COOKIE 0x0800
#define PyCF_TYPE_COMMENTS 0x1000
#define PyCF_ALLOW_TOP_LEVEL_AWAIT 0x2000
#define PyCF_COMPILE_MASK (PyCF_ONLY_AST | PyCF_ALLOW_TOP_LEVEL_AWAIT | \
PyCF_TYPE_COMMENTS | PyCF_DONT_IMPLY_DEDENT)

#ifndef Py_LIMITED_API
typedef struct {
Expand Down
16 changes: 8 additions & 8 deletions Lib/__future__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@
# this module.
CO_NESTED = 0x0010 # nested_scopes
CO_GENERATOR_ALLOWED = 0 # generators (obsolete, was 0x1000)
CO_FUTURE_DIVISION = 0x2000 # division
CO_FUTURE_ABSOLUTE_IMPORT = 0x4000 # perform absolute imports by default
CO_FUTURE_WITH_STATEMENT = 0x8000 # with statement
CO_FUTURE_PRINT_FUNCTION = 0x10000 # print function
CO_FUTURE_UNICODE_LITERALS = 0x20000 # unicode string literals
CO_FUTURE_BARRY_AS_BDFL = 0x40000
CO_FUTURE_GENERATOR_STOP = 0x80000 # StopIteration becomes RuntimeError in generators
CO_FUTURE_ANNOTATIONS = 0x100000 # annotations become strings at runtime
CO_FUTURE_DIVISION = 0x20000 # division
CO_FUTURE_ABSOLUTE_IMPORT = 0x40000 # perform absolute imports by default
CO_FUTURE_WITH_STATEMENT = 0x80000 # with statement
CO_FUTURE_PRINT_FUNCTION = 0x100000 # print function
CO_FUTURE_UNICODE_LITERALS = 0x200000 # unicode string literals
CO_FUTURE_BARRY_AS_BDFL = 0x400000
CO_FUTURE_GENERATOR_STOP = 0x800000 # StopIteration becomes RuntimeError in generators
CO_FUTURE_ANNOTATIONS = 0x1000000 # annotations become strings at runtime

class _Feature:
def __init__(self, optionalRelease, mandatoryRelease, compiler_flag):
Expand Down
17 changes: 17 additions & 0 deletions Lib/test/test_future.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -75,6 +77,21 @@ def test_badfuture10(self):
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 |= {
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
Expand Down
2 changes: 1 addition & 1 deletion Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
}

if (flags &
~(PyCF_MASK | PyCF_MASK_OBSOLETE | PyCF_DONT_IMPLY_DEDENT | PyCF_ONLY_AST | PyCF_TYPE_COMMENTS))
~(PyCF_MASK | PyCF_MASK_OBSOLETE | PyCF_COMPILE_MASK))
{
PyErr_SetString(PyExc_ValueError,
"compile(): unrecognised flags");
Expand Down