summaryrefslogtreecommitdiff
path: root/Python/symtable.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35177, Python-ast.h: Fix "Yield" compiler warning (GH-10664)Victor Stinner2018-11-221-0/+1
| | | | | | | | Partially revert commit 5f2df88b63e50d23914e97ec778861a52abdeaad: add "#undef Yield" to .c files after including Python-ast.h. Fix the warning: winbase.h(102): warning C4005: 'Yield': macro redefinition
* Add a missed PyErr_NoMemory() in symtable_new(). (GH-10576)Zackery Spytz2018-11-161-1/+3
| | | | This missed PyErr_NoMemory() could cause a SystemError when calling _symtable.symtable().
* bpo-35081: Rename internal headers (GH-10275)Victor Stinner2018-11-121-1/+1
| | | | | | | | | | | | | | Rename Include/internal/ headers: * pycore_hash.h -> pycore_pyhash.h * pycore_lifecycle.h -> pycore_pylifecycle.h * pycore_mem.h -> pycore_pymem.h * pycore_state.h -> pycore_pystate.h Add missing headers to Makefile.pre.in and PCbuild: * pycore_condvar.h. * pycore_hamt.h * pycore_pyhash.h
* bpo-35177: Add dependencies between header files (GH-10361)Victor Stinner2018-11-121-5/+0
| | | | | | | | | | | | | | * ast.h now includes Python-ast.h and node.h * parsetok.h now includes node.h and grammar.h * symtable.h now includes Python-ast.h * Modify asdl_c.py to enhance Python-ast.h: * Add #ifndef/#define Py_PYTHON_AST_H to be able to include the header twice * Add "extern { ... }" for C++ * Undefine "Yield" macro conflicting with winbase.h * Remove "#undef Yield" from C files, it's now done in Python-ast.h * Remove now useless includes in C files
* bpo-35081: Add _PyThreadState_GET() internal macro (GH-10266)Victor Stinner2018-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | If Py_BUILD_CORE is defined, the PyThreadState_GET() macro access _PyRuntime which comes from the internal pycore_state.h header. Public headers must not require internal headers. Move PyThreadState_GET() and _PyInterpreterState_GET_UNSAFE() from Include/pystate.h to Include/internal/pycore_state.h, and rename PyThreadState_GET() to _PyThreadState_GET() there. The PyThreadState_GET() macro of pystate.h is now redefined when pycore_state.h is included, to use the fast _PyThreadState_GET(). Changes: * Add _PyThreadState_GET() macro * Replace "PyThreadState_GET()->interp" with _PyInterpreterState_GET_UNSAFE() * Replace PyThreadState_GET() with _PyThreadState_GET() in internal C files (compiled with Py_BUILD_CORE defined), but keep PyThreadState_GET() in the public header files. * _testcapimodule.c: replace PyThreadState_GET() with PyThreadState_Get(); the module is not compiled with Py_BUILD_CORE defined. * pycore_state.h now requires Py_BUILD_CORE to be defined.
* bpo-35081: Add pycore_ prefix to internal header files (GH-10263)Victor Stinner2018-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | * Rename Include/internal/ header files: * pyatomic.h -> pycore_atomic.h * ceval.h -> pycore_ceval.h * condvar.h -> pycore_condvar.h * context.h -> pycore_context.h * pygetopt.h -> pycore_getopt.h * gil.h -> pycore_gil.h * hamt.h -> pycore_hamt.h * hash.h -> pycore_hash.h * mem.h -> pycore_mem.h * pystate.h -> pycore_state.h * warnings.h -> pycore_warnings.h * PCbuild project, Makefile.pre.in, Modules/Setup: add the Include/internal/ directory to the search paths of header files. * Update includes. For example, replace #include "internal/mem.h" with #include "pycore_mem.h".
* bpo-34939: Allow annotated global names in module namespace (GH-9844)Pablo Galindo2018-10-141-0/+1
| | | | | | | Allow annotated global names in the module namespace after the symbol is declared as global. Previously, only symbols annotated before they are declared as global (i.e. inside a function) were allowed. This change allows symbols to be declared as global before the annotation happens in the global scope.
* Fix a possible decref of a borrowed reference in symtable.c. (GH-9786)Zackery Spytz2018-10-111-2/+4
|
* bpo-32892: Use ast.Constant instead of specific constant AST types. (GH-9445)Serhiy Storchaka2018-09-271-5/+0
|
* bpo-34683: Make SyntaxError column offsets consistently 1-indexed (gh-9338)Ammar Askar2018-09-241-7/+7
| | | | | | Also point to start of tokens in parsing errors. Fixes bpo-34683
* bpo-32836: Remove obsolete code from symtable pass (GH-5680)Nitish Chandra2018-02-271-25/+0
| | | | | | | When comprehensions switched to using a nested scope, the old code for generating a temporary name to hold the accumulation target became redundant, but was never actually removed. Patch by Nitish Chandra.
* bpo-10544: Disallow "yield" in comprehensions and generator expressions. ↵Serhiy Storchaka2018-02-041-24/+7
| | | | (GH-4564)
* bpo-10544: Deprecate "yield" in comprehensions and generator expressions. ↵Serhiy Storchaka2017-12-011-1/+30
| | | | | | | | | | | | | | (GH-4579) The current behaviour of yield expressions inside comprehensions and generator expressions is essentially an accident of implementation - it arises implicitly from the way the compiler handles yield expressions inside nested functions and generators. Since the current behaviour wasn't deliberately designed, and is inherently confusing, we're deprecating it, with no current plans to reintroduce it. Instead, our advice will be to use a named nested generator definition for cases where this behaviour is desired.
* bpo-28936: Detect lexically first syntax error first (#4097)Ivan Levkivskyi2017-10-271-18/+16
| | | | Lexically first global and nonlocal syntax errors at given scope should be detected first.
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-071-0/+4
| | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka2016-11-161-2/+2
|\ | | | | | | | | | | _PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
| * Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka2016-11-161-2/+2
| | | | | | | | | | | | _PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
* | Issue #28100: Refactor error messages, patch by Ivan LevkivskyiChristian Heimes2016-09-231-12/+8
| |
* | Issue #28008: Implement PEP 530 -- asynchronous comprehensions.Yury Selivanov2016-09-091-0/+6
| |
* | Issue #27999: Make "global after use" a SyntaxError, and ditto for nonlocal.Guido van Rossum2016-09-091-68/+36
| | | | | | | | Patch by Ivan Levkivskyi.
* | Issue #28003: Implement PEP 525 -- Asynchronous Generators.Yury Selivanov2016-09-081-2/+4
| |
* | Issue #27985: Implement PEP 526 -- Syntax for Variable Annotations.Yury Selivanov2016-09-081-0/+56
| | | | | | | | Patch by Ivan Levkivskyi.
* | Fix potential NULL pointer dereference in update_symbols()Christian Heimes2016-09-091-1/+1
| | | | | | | | | | | | symtable_analyze() calls analyze_block() with bound=NULL. Theoretically that NULL can be passed down to update_symbols(). update_symbols() may deference NULL and pass it to PySet_Contains()
* | Merge typo fixes from 3.5Martin Panter2016-06-041-1/+1
|\ \ | |/
| * Fix typos in code comment and documentationMartin Panter2016-06-041-1/+1
| |
* | Add ast.ConstantVictor Stinner2016-01-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #26146: Add a new kind of AST node: ast.Constant. It can be used by external AST optimizers, but the compiler does not emit directly such node. An optimizer can replace the following AST nodes with ast.Constant: * ast.NameConstant: None, False, True * ast.Num: int, float, complex * ast.Str: str * ast.Bytes: bytes * ast.Tuple if items are constants too: tuple * frozenset Update code to accept ast.Constant instead of ast.Num and/or ast.Str: * compiler * docstrings * ast.literal_eval() * Tools/parser/unparse.py
* | merge 3.5 (#25973)Benjamin Peterson2015-12-291-8/+16
|\ \ | |/
| * make recording and reporting errors and nonlocal and global directives more ↵Benjamin Peterson2015-12-291-8/+16
| | | | | | | | robust (closes #25973)
* | Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka2015-12-251-2/+2
| | | | | | | | private functions.
* | Issue #24965: Implement PEP 498 "Literal String Interpolation". ↵Eric V. Smith2015-09-191-0/+8
|/ | | | Documentation is still needed, I'll open an issue for that.
* Issue #24619: More tests; fix nits in compiler.cYury Selivanov2015-07-221-1/+1
|
* Issue #19235: Add new RecursionError exception. Patch by Georg Brandl.Yury Selivanov2015-07-031-2/+2
|
* PEP 0492 -- Coroutines with async and await syntax. Issue #24017.Yury Selivanov2015-05-111-6/+43
|
* PEP 448: additional unpacking generalizations (closes #2292)Benjamin Peterson2015-05-051-18/+8
| | | | Patch by Neil Girdhar.
* remove the concept of an unoptimized function scope from the compiler, since ↵Benjamin Peterson2015-04-271-16/+0
| | | | it can't happen anymore
* remove dead *-import checking code (closes #24049)Benjamin Peterson2015-04-241-31/+0
|
* merge 3.3 (#19098)Benjamin Peterson2013-09-261-2/+6
|\
| * don't scale compiler stack frames if the recursion limit is huge (closes #19098)Benjamin Peterson2013-09-261-2/+6
| |
| * move definition to top of blockBenjamin Peterson2013-05-161-1/+2
| |
| * complain about "global __class__" in a class body (closes #17983)Benjamin Peterson2013-05-151-0/+6
| |
* | Close #11619: The parser and the import machinery do not encode UnicodeVictor Stinner2013-08-261-15/+40
| | | | | | | | filenames anymore on Windows.
* | Issue #18408: ste_new() initialize all attributes before handling errorVictor Stinner2013-07-111-13/+9
| | | | | | | | If an attribute is not initialized, the destructor can crash
* | rather than passing locals to the class body, just execute the class body in ↵Benjamin Peterson2013-05-161-6/+1
| | | | | | | | the proper environment
* | hide the __class__ closure from the class body (#12370)Benjamin Peterson2013-05-151-15/+19
| |
* | unify some ast.argument's attrs; change Attribute column offset (closes #16795)Benjamin Peterson2013-03-181-6/+6
| | | | | | | | Patch from Sven Brauch.
* | create NameConstant AST class for None, True, and False literals (closes #16619)Benjamin Peterson2012-12-061-0/+1
| |
* | Issue #16546: merge fix from 3.3Mark Dickinson2012-11-251-6/+6
|\ \ | |/
| * Issue #16546: make ast.YieldFrom argument mandatory.Mark Dickinson2012-11-251-6/+6
| |
* | Issue #5765: Merge from 3.3Nick Coghlan2012-11-041-31/+70
|\ \ | |/
| * Issue #5765: Apply a hard recursion limit in the compilerNick Coghlan2012-11-041-29/+68
| | | | | | | | | | | | | | Previously, excessive nesting in expressions would blow the stack and segfault the interpreter. Now, a hard limit based on the configured recursion limit and a hardcoded scaling factor is applied.