Serhiy Storchaka
91fc9cf43c
[3.7] bpo-38535: Fix positions for AST nodes for calls without arguments in decorators. (GH-16861). (GH-16930)
...
(cherry picked from commit 26ae9f6d3d
)
2019-10-26 17:30:14 +03:00
Miss Islington (bot)
d3d2650cf8
bpo-37950: Fix ast.dump() when call with incompletely initialized node. (GH-15510)
...
(cherry picked from commit e64f948e76
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2019-08-29 00:04:44 -07:00
Serhiy Storchaka
c238862292
bpo-36917: Backport basic test for ast.NodeVisitor. (GH-15511)
2019-08-26 14:48:55 +03:00
Miss Islington (bot)
d8bc7a666b
closes bpo-31902: Fix the col_offset attribute for ast.Async* nodes to point to the "async" keyword. (GH-4175)
...
Previously, col_offset points to the keyword after "async".
(cherry picked from commit 90fc8980bb
)
Co-authored-by: guoci <zguoci@gmail.com>
2018-09-11 15:21:11 -07:00
Miss Islington (bot)
a50b825c18
bpo-33851: Fix ast.get_docstring() for a node that lacks a docstring. (GH-7682)
...
(cherry picked from commit 08f127a3ca
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-06-15 01:25:13 -07:00
Serhiy Storchaka
2641ee5040
bpo-32911: Revert bpo-29463. (GH-7121)
...
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 10:49:10 +03:00
Serhiy Storchaka
d8ac4d1d5a
bpo-31778: Make ast.literal_eval() more strict. ( #4035 )
...
Addition and subtraction of arbitrary numbers no longer allowed.
2018-01-04 11:15:39 +02:00
Oren Milman
7dc46d8cf5
bpo-31592: Fix an assertion failure in Python parser in case of a bad unicodedata.normalize(). ( #3767 )
2017-09-30 20:16:24 +03:00
Matthias Bussonnier
41cea70aa3
bpo-29637: clean docstring only if not None (GH-267)
2017-02-24 15:44:19 +09:00
INADA Naoki
4c78c527d2
bpo-29622: Make AST constructor to accept less than enough number of positional arguments (GH-249)
...
bpo-29463 added optional "docstring" field to 4 AST types.
While it is optional, it breaks backward compatibility because AST constructor
requires number of positional argument is same to number of fields.
AST types accepts empty arguments, and incomplete keyword arguments.
But it's not big problem because field can be filled after creation, and checked when compiling.
So stop requiring complete set of fields for positional arguments too.
2017-02-24 02:48:17 +09: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
Yury Selivanov
52c4e7cc84
Issue #28008 : Implement PEP 530 -- asynchronous comprehensions.
2016-09-09 10:36:01 -07:00
Serhiy Storchaka
7de2840508
Issue #27352 : Fixed an error message in a test.
2016-06-27 23:40:43 +03:00
Berker Peksag
0a5bd51dd3
Issue #13436 : Add a test to make sure that ast.ImportFrom(level=None) works
2016-04-29 19:50:02 +03:00
Victor Stinner
15a3095d64
compiler: don't emit SyntaxWarning on const stmt
...
Issue #26204 : the compiler doesn't emit SyntaxWarning warnings anymore when
constant statements are ignored.
2016-02-08 22:45:06 +01:00
Victor Stinner
a2724095cd
compiler now ignores constant statements
...
The compile ignores constant statements and emit a SyntaxWarning warning.
Don't emit the warning for string statement because triple quoted string is a
common syntax for multiline comments.
Don't emit the warning on ellipis neither: 'def f(): ...' is a legit syntax for
abstract functions.
Changes:
* test_ast: ignore SyntaxWarning when compiling test statements. Modify
test_load_const() to use assignment expressions rather than constant
expression.
* test_code: add more kinds of constant statements, ignore SyntaxWarning when
testing that the compiler removes constant statements.
* test_grammar: ignore SyntaxWarning on the statement "1"
2016-02-08 18:17:58 +01:00
Victor Stinner
f089196beb
Simplify main() of test_ast
...
* Use ast.parse() to get the AST for a statement
* Use str%args syntax for format a line
Issue #26204 .
2016-02-08 17:15:21 +01:00
Victor Stinner
be59d1489b
Issue #26146 : enhance ast.Constant error message
...
Mention the name of the invalid type in error message of AST validation for
constants.
Suggestion made by Joseph Jevnik on a review.
2016-01-27 00:39:12 +01:00
Victor Stinner
f2c1aa1661
Add ast.Constant
...
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
2016-01-26 00:40:57 +01:00
Benjamin Peterson
58b53953f8
make opening brace of container literals and comprehensions correspond to the line number and col offset of the AST node ( closes #25131 )
2015-09-25 22:44:43 -07:00
Yury Selivanov
b3d531348c
Issue #24975 : Fix AST compilation for PEP 448 syntax.
2015-09-01 16:10:49 -04:00
Yury Selivanov
2f07a66ded
Issue #24688 : ast.get_docstring() for 'async def' functions.
2015-07-23 08:54:35 +03:00
Yury Selivanov
7544508f02
PEP 0492 -- Coroutines with async and await syntax. Issue #24017 .
2015-05-11 22:57:16 -04:00
Benjamin Peterson
025e9ebd0a
PEP 448: additional unpacking generalizations ( closes #2292 )
...
Patch by Neil Girdhar.
2015-05-05 20:16:41 -04:00
Benjamin Peterson
7a66fc22ad
revert lineno and col_offset changes from #16795 ( closes #21295 )
2015-02-02 10:51:20 -05:00
Benjamin Peterson
e84fde981d
set line and column numbers for keyword-only arg nodes ( closes #20619 )
2014-02-13 19:22:14 -05:00
Ezio Melotti
a7e7497d88
#18466 : merge with 3.3.
2013-08-17 16:58:13 +03:00
Ezio Melotti
85a8629d21
#18466 : fix more typos. Patch by Févry Thibault.
2013-08-17 16:57:41 +03:00
Brett Cannon
3e9a9ae09d
Update various test modules to use unittest.main() for test discovery
...
instead of manually listing tests for test.support.run_unittest().
2013-06-12 21:25:59 -04:00
Victor Stinner
d502a07fac
test_ast: pass the filename to ast.parse()
2013-03-22 00:06:20 +01:00
Benjamin Peterson
cda75be02a
unify some ast.argument's attrs; change Attribute column offset ( closes #16795 )
...
Patch from Sven Brauch.
2013-03-18 10:48:58 -07:00
Benjamin Peterson
442f20996d
create NameConstant AST class for None, True, and False literals ( closes #16619 )
2012-12-06 17:41:04 -05:00
Mark Dickinson
ded35aeb9d
Issue #16546 : make ast.YieldFrom argument mandatory.
2012-11-25 14:36:26 +00:00
Benjamin Peterson
bd0df50fb6
get rid of ast_error_finish by passing the compiling struct to ast_error
2012-09-02 15:04:51 -04:00
Benjamin Peterson
c7f447c89f
merge 3.2 ( #15846 )
2012-09-02 14:24:44 -04:00
Benjamin Peterson
2e2c903700
prevert ast errors from being normalized before ast_error_finish is called ( closes #15846 )
2012-09-02 14:23:15 -04:00
Benjamin Peterson
9ed37433c4
test AST base type garbage collection
2012-07-08 11:13:36 -07:00
Benjamin Peterson
98ba753432
merge 3.2 ( #14378 )
2012-03-22 08:19:50 -04:00
Benjamin Peterson
a4e4e35783
check by equality for __future__ not identity ( closes #14378 )
2012-03-22 08:19:04 -04:00
Benjamin Peterson
7e0dbfbbde
give the AST class a __dict__
2012-03-12 09:46:44 -07:00
Benjamin Peterson
61a4161de4
merge 3.2
2012-03-12 09:43:27 -07:00
Benjamin Peterson
ef87f06798
allow AST objects to be like its subclasses
2012-03-12 09:43:09 -07:00
Benjamin Peterson
09b4bd03f6
merge 3.2
2012-03-12 09:28:36 -07:00
Benjamin Peterson
d279e286f2
every other ast object has a dict, so I think AST should, too
2012-03-12 09:27:36 -07:00
Benjamin Peterson
527c622926
make YieldFrom its own distinct from Yield ( closes #13780 )
2012-01-14 08:58:23 -05:00
Nick Coghlan
1f7ce62bd6
Implement PEP 380 - 'yield from' ( closes #11682 )
2012-01-13 21:43:40 +10:00
Amaury Forgeot d'Arc
942d5ba125
Merge branch 3.2
2011-11-22 22:02:01 +01:00
Amaury Forgeot d'Arc
58e8761da6
Issue #13436 : Fix a bogus error message when an AST object was passed
...
an invalid integer value.
2011-11-22 21:51:55 +01:00
Florent Xicluna
e41f0de84d
Merge 3.2, fix typos.
2011-11-11 19:39:25 +01:00
Florent Xicluna
992d9e081f
Fix few typos.
2011-11-11 19:35:42 +01:00