INADA Naoki
f7e4d3642f
bpo-34100: compile: Re-enable frozenset merging (GH-10760)
...
This reverts commit 1005c84535
.
2018-11-28 16:58:46 +01:00
Victor Stinner
1005c84535
bpo-34100: Partially revert merge_consts_recursive() (GH-10743)
...
Partically revert commit c2e1607a51
to
fix a reference leak.
2018-11-27 15:12:47 +01:00
INADA Naoki
c2e1607a51
bpo-34100: Merge constants recursively (GH-8341)
...
There are some same consts in a module. This commit merges them into
single instance. It reduces number of objects in memory after loading modules.
https://bugs.python.org/issue34100
2018-11-26 04:23:22 -08:00
Victor Stinner
5f2df88b63
bpo-35177: Add dependencies between header files (GH-10361)
...
* 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
2018-11-12 00:56:19 +01:00
Serhiy Storchaka
95b6acf951
bpo-34876: Change the lineno of the AST for decorated function and class. (GH-9731)
...
It was overridden by the lineno of the first decorator. Now it is
the lineno of 'def' or 'class'.
2018-10-30 13:16:02 +02:00
Serhiy Storchaka
d31e7730cd
bpo-35029: Replace the SyntaxWarning exception with a SyntaxError. (GH-9999)
...
If SyntaxWarning was raised as an exception, it will be replaced
with a SyntaxError for better error reporting.
2018-10-21 10:09:39 +03:00
Zackery Spytz
53ebf4b070
Fix an incorrect check in compiler_try_except(). (GH-9810)
2018-10-12 08:54:03 +03:00
Serhiy Storchaka
3f22811fef
bpo-32892: Use ast.Constant instead of specific constant AST types. (GH-9445)
2018-09-27 17:42:37 +03:00
Ammar Askar
025eb98dc0
bpo-34683: Make SyntaxError column offsets consistently 1-indexed (gh-9338)
...
Also point to start of tokens in parsing errors.
Fixes bpo-34683
2018-09-24 14:12:49 -07:00
Serhiy Storchaka
7bdf28265a
bpo-32455: Add jump parameter to dis.stack_effect(). (GH-6610)
...
Add C API function PyCompile_OpcodeStackEffectWithJump().
2018-09-18 09:54:26 +03:00
Serhiy Storchaka
da8d72c953
bpo-12458: Fix line numbers for multiline expressions. (GH-8774)
2018-09-17 15:17:29 +03:00
Benjamin Peterson
e502451781
closes bpo-34646: Remove PyAPI_* macros from declarations. (GH-9218)
2018-09-12 12:06:42 -07:00
Serhiy Storchaka
143ce5c6db
bpo-33691: Add _PyAST_GetDocString(). (GH-7236)
2018-05-30 10:56:16 +03:00
Serhiy Storchaka
73cbe7a01a
bpo-32911: Revert bpo-29463. (GH-7121) (GH-7197)
...
Remove the docstring attribute of AST types and restore docstring
expression as a first stmt in their body.
Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
2018-05-29 12:04:55 +03:00
Serhiy Storchaka
64fddc423f
bpo-33475: Fix and improve converting annotations to strings. (GH-6774)
2018-05-16 23:17:48 -04:00
Zsolt Dollenstein
e239650660
bpo-33363: raise SyntaxError for async for/with outside async functions ( #6616 )
2018-04-27 11:58:56 -04:00
Serhiy Storchaka
57faf34887
bpo-33334: Support NOP and EXTENDED_ARG in dis.stack_effect(). ( #6566 )
...
Added tests to ensure that all defined opcodes are supported.
2018-04-25 22:04:06 +03:00
Serhiy Storchaka
d70c2a6894
bpo-33298: Wrap only constants with _PyCode_ConstantKey() in the compiler. (GH-6512)
2018-04-20 16:01:25 +03:00
Serhiy Storchaka
b7e1eff843
bpo-33299: Return an object itself for some types in _PyCode_ConstantKey(). (GH-6513)
2018-04-19 08:28:04 +03:00
Zackery Spytz
f303639e3a
bpo-33270: Intern names for all anonymous code objects ( #6472 )
2018-04-16 01:12:29 +03:00
Serhiy Storchaka
aa8e51f5eb
bpo-33132: Fix more reference counting issues in the compiler. (GH-6323)
2018-04-01 00:29:37 +03:00
Serhiy Storchaka
a95d98607e
bpo-33132: Fix reference counting issues in the compiler. (GH-6209)
2018-03-24 22:42:35 +02:00
Serhiy Storchaka
702f8f3611
bpo-33041: Rework compiling an "async for" loop. ( #6142 )
...
* Added new opcode END_ASYNC_FOR.
* Setting global StopAsyncIteration no longer breaks "async for" loops.
* Jumping into an "async for" loop is now disabled.
* Jumping out of an "async for" loop no longer corrupts the stack.
* Simplify the compiler.
2018-03-23 14:34:35 +02:00
Serhiy Storchaka
fe2bbb1869
bpo-32489: Allow 'continue' in 'finally' clause. (GH-5822)
2018-03-18 09:56:52 +02:00
Serhiy Storchaka
67ee07795b
bpo-33041: Add missed error checks when compile "async for" ( #6053 )
...
and remove redundant code.
2018-03-10 18:49:26 +02:00
Serhiy Storchaka
24d3201eb7
bpo-33041: Fixed bytecode generation for "async for" with a complex target. ( #6052 )
...
A StopAsyncIteration raised on assigning or unpacking will be now propagated
instead of stopping the iteration.
2018-03-10 18:22:34 +02:00
Serhiy Storchaka
520b7ae27e
bpo-17611. Move unwinding of stack for "pseudo exceptions" from interpreter to compiler. (GH-5006)
...
Co-authored-by: Mark Shannon <mark@hotpy.org>
Co-authored-by: Antoine Pitrou <antoine@python.org>
2018-02-22 23:33:30 +02:00
Mark Shannon
332cd5ee4f
bpo-32550. Remove the STORE_ANNOTATION bytecode. (GH-5181)
2018-01-29 16:41:04 -08:00
Guido van Rossum
95e4d58913
String annotations [PEP 563] ( #4390 )
...
* Document `from __future__ import annotations`
* Provide plumbing and tests for `from __future__ import annotations`
* Implement unparsing the AST back to string form
This is required for PEP 563 and as such only implements a part of the
unparsing process that covers expressions.
2018-01-26 08:20:18 -08:00
Serhiy Storchaka
782d6fe443
bpo-31113: Get rid of recursion in the compiler for normal control flow. ( #3015 )
2018-01-11 20:20:13 +02:00
Serhiy Storchaka
d4864c61e3
bpo-24340: Fix estimation of the code stack size. ( #5076 )
2018-01-09 21:54:52 +02:00
Serhiy Storchaka
02b9ef2775
bpo-32439: Clean up the code for compiling comparison expressions. ( #5029 )
2017-12-30 09:47:42 +02:00
Serhiy Storchaka
3dfbaf51f0
bpo-32372: Move __debug__ optimization to the AST level. ( #4925 )
2017-12-25 12:47:50 +02:00
Serhiy Storchaka
bd6ec4d79e
bpo-32365: Fix a reference leak when compile __debug__. ( #4916 )
...
It was introduced in bpo-27169.
2017-12-18 14:29:12 +02:00
Serhiy Storchaka
3325a6780c
bpo-27169: The __debug__ constant is now optimized out at compile time. ( #4880 )
...
This fixes also bpo-22091.
2017-12-15 12:35:48 +02:00
INADA Naoki
7ea143ae79
bpo-29469: Move constant folding to AST optimizer (GH-2858)
2017-12-14 16:47:20 +09:00
Nick Coghlan
078f1814f1
bpo-32176: Set CO_NOFREE in the code object constructor (GH-4675)
...
Previously, CO_NOFREE was set in the compiler, which meant
it could end up being set incorrectly when code objects
were created directly. Setting it in the constructor based
on freevars and cellvars ensures it is always accurate,
regardless of how the code object is defined.
2017-12-03 11:12:20 +10:00
Serhiy Storchaka
e2f92de6a9
Add the const qualifier to "char *" variables that refer to literal strings. ( #4370 )
2017-11-11 13:06:26 +02:00
Yury Selivanov
b8ab9d3fc8
bpo-31708: Allow async generator expressions in synchronous functions ( #3905 )
2017-10-06 02:58:28 -04:00
Yury Selivanov
faa135acbf
bpo-31709: Drop support for asynchronous __aiter__. ( #3903 )
2017-10-06 02:08:57 -04:00
Barry Warsaw
b2e5794870
bpo-31338 ( #3374 )
...
* Add Py_UNREACHABLE() as an alias to abort().
* Use Py_UNREACHABLE() instead of assert(0)
* Convert more unreachable code to use Py_UNREACHABLE()
* Document Py_UNREACHABLE() and a few other macros.
2017-09-14 18:13:16 -07:00
Serhiy Storchaka
265fcc5fc2
bpo-31286, bpo-30024: Fixed stack usage in absolute imports with ( #3217 )
...
binding a submodule to a name.
2017-08-29 15:47:44 +03:00
Stefan Krah
f432a3234f
bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0. ( #3157 )
2017-08-21 13:09:59 +02:00
Serhiy Storchaka
36ff451eba
bpo-30501: Make the compiler producing optimized code for condition expressions. ( #1851 )
2017-06-11 14:50:22 +03:00
Serhiy Storchaka
f93234bb8a
bpo-30024: Circular imports involving absolute imports with binding ( #1264 )
...
a submodule to a name are now supported.
2017-05-09 22:31:05 +03:00
Serhiy Storchaka
ba85d69a3e
bpo-29878: Add global instances of int for 0 and 1. ( #852 )
2017-03-30 09:09:41 +03:00
INADA Naoki
cb41b2766d
bpo-29463: Add docstring field to some AST nodes. ( #46 )
...
* bpo-29463: Add docstring field to some AST nodes.
ClassDef, ModuleDef, FunctionDef, and AsyncFunctionDef has docstring
field for now. It was first statement of there body.
* fix document. thanks travis!
* doc fixes
2017-02-22 16:31:59 +01:00
Matthieu Dartiailh
3a9ac827c7
bpo-29607: Fix stack_effect computation for CALL_FUNCTION_EX ( #202 )
2017-02-21 15:25:22 +02:00
Serhiy Storchaka
5ab81d787f
Issue #28959 : Added private macro PyDict_GET_SIZE for retrieving the size of dict.
2016-12-16 16:18:57 +02:00
Yury Selivanov
f2392133eb
Issue #26110 : Add LOAD_METHOD/CALL_METHOD opcodes.
...
Special thanks to INADA Naoki for pushing the patch through
the last mile, Serhiy Storchaka for reviewing the code, and to
Victor Stinner for suggesting the idea (originally implemented
in the PyPy project).
2016-12-13 19:03:51 -05:00