Commit Graph

109 Commits

Author SHA1 Message Date
Victor Stinner 25219f596a Issue #26146: remove useless code
obj2ast_constant() code is baesd on obj2ast_object() which has a special case
for Py_None. But in practice, we don't need to have a special case for
constants.

Issue noticed by Joseph Jevnik on a review.
2016-01-27 00:37:59 +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
Victor Stinner c106c68aeb Issue #25555: Fix parser and AST: fill lineno and col_offset of "arg" node when
compiling AST from Python objects.
2015-11-06 17:01:48 +01:00
Benjamin Peterson 860c8a404a merge 3.5 (#25502) 2015-10-28 23:15:22 -07:00
Benjamin Peterson 669ff66c32 remove duplicated imports (closes #25502) 2015-10-28 23:15:13 -07:00
Serhiy Storchaka fc632e3912 Merge with 3.5. 2015-10-06 18:52:52 +03:00
Serhiy Storchaka 481d3af82e Make asdl_c.py to generate Python-ast.c changed in issue #15989. 2015-09-06 23:29:04 +03:00
Eli Bendersky 5e3d338a74 Issue #19655: Replace the ASDL parser carried with CPython
The new parser does not rely on Spark (which is now removed from our repo),
uses modern 3.x idioms and is significantly smaller and simpler.

It generates exactly the same AST files (.h and .c), so in practice no builds
should be affected.
2014-05-09 17:58:22 -07:00
Benjamin Peterson 42ec031fe7 merge 3.3 (#20588) 2014-02-10 22:41:40 -05:00
Benjamin Peterson c2f665e721 don't put runtime values in array initializer for C89 compliance (closes #20588) 2014-02-10 22:19:02 -05:00
Antoine Pitrou d01d396e7f Issue #4555: All exported C symbols are now prefixed with either "Py" or "_Py".
("make smelly" now clean)
2013-10-12 22:52:43 +02:00
Ezio Melotti d640fe2af5 #18803: merge with 3.3. 2013-08-26 01:33:30 +03:00
Ezio Melotti 7c4a7e6f3c #18803: fix more typos. Patch by Févry Thibault. 2013-08-26 01:32:56 +03:00
Christian Heimes b7f1b38dea Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object(). 2013-07-27 00:33:35 +02:00
Christian Heimes 70c94e7896 Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object(). 2013-07-27 00:33:13 +02:00
Victor Stinner b318990cac (Merge 3.3) Parser/asdl_c.py: use Py_CLEAR() 2013-07-27 00:04:42 +02:00
Victor Stinner 1acc129d48 Parser/asdl_c.py: use Py_CLEAR() 2013-07-27 00:03:47 +02:00
Victor Stinner ee4b59c0f8 (Merge 3.3) According to the PEP 7, C code must "use 4-space indents"
Replace 8 spaces with 4.
2013-07-27 00:01:35 +02:00
Victor Stinner ce72e1ce6c According to the PEP 7, C code must "use 4-space indents"
Replace 8 spaces with 4.
2013-07-27 00:00:36 +02:00
Victor Stinner bdf630c4a7 Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError) 2013-07-17 00:17:15 +02:00
Benjamin Peterson 8d89c2aaba change AST codegen to use PyModule_AddIntMacro 2013-05-20 10:28:48 -07:00
Benjamin Peterson 7654ab9ef0 placate msvc 2013-03-18 23:39:53 -07:00
Benjamin Peterson b72406b8fa refactor to fix refleaks 2013-03-18 23:24:41 -07: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
Matthias Klose aee3c76acf - Issue #16262: fix out-of-src-tree builds, if mercurial is not installed. 2012-10-21 23:12:35 +02:00
Ezio Melotti 8a9cc526fe #15923: merge with 3.2. 2012-09-30 22:47:47 +03:00
Ezio Melotti cb2916a714 #15923: fix a mistake in asdl_c.py that resulted in a TypeError after 2801bf875a24 (see #15801). 2012-09-30 22:41:37 +03:00
Benjamin Peterson 8107176f9b add gc support to the AST base type (closes #15293) 2012-07-08 11:03:46 -07:00
Antoine Pitrou 507507473e Issue #15291: Fix a memory leak where AST nodes where not properly deallocated. 2012-07-08 12:43:32 +02:00
Benjamin Peterson 77fa9379e2 use Py_ssize_t for ast sequence lengths 2012-05-15 10:10:27 -07:00
Benjamin Peterson 1767e0274b free AST's dict 2012-03-14 21:50:29 -05:00
Victor Stinner 45e50de1f5 Try to fix compilation of Python-ast.c on Visual Studio 2008 2012-03-13 01:17:31 +01:00
Benjamin Peterson 7e0dbfbbde give the AST class a __dict__ 2012-03-12 09:46:44 -07:00
Benjamin Peterson f51d36a743 evidently some buildbots don't have python 3 installed 2011-12-29 12:07:21 -06:00
Benjamin Peterson 3ab85886d6 run AST toolchain on python3 2011-12-29 12:03:55 -06: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
Meador Inge 70d86bdef1 Issue 13243: Rename _Py_identifier to _Py_IDENTIFIER in asdl_c.py
Parser/asdl_c.py was missed in commit 7109f31300fb when _Py_identifier
was replaced with _Py_IDENTIFIER.  Thanks to Eric Snow for the patch.
2011-10-22 14:06:50 -05:00
Martin v. Löwis 1c67dd9b15 Port SetAttrString/HasAttrString to SetAttrId/GetAttrId. 2011-10-14 15:16:45 +02:00
Martin v. Löwis 1ee1b6fe0d Use identifier API for PyObject_GetAttrString. 2011-10-10 18:11:30 +02:00
Éric Araujo 6f08f53e79 Merge 3.2 2011-09-02 17:32:30 +02:00
Benjamin Peterson 0224d4e699 accept bytes for the AST 'string' type
This is a temporary kludge and all is well in 3.3.
2011-08-31 22:13:03 -04:00
Benjamin Peterson 5a3f49bb7e revert code which conditionally writes Python-ast.h (closes #12727) 2011-08-11 14:42:28 -05:00
Benjamin Peterson 257a1d0f28 2.x syntax 2011-08-09 18:48:02 -05:00
Benjamin Peterson 4ec450d3c7 make this work on 2.4 2011-08-09 18:38:57 -05:00
Benjamin Peterson 6f7500424c make this work with py2.5 2011-08-09 16:49:52 -05:00
Benjamin Peterson 398256b230 don't rewrite the header file if it hasn't changed; this reduces development build time 2011-08-09 16:28:58 -05:00
Benjamin Peterson e249841903 add a asdl bytes type, so Bytes.s be properly typechecked 2011-08-09 16:08:39 -05:00
Benjamin Peterson 8a4b42b7f4 merge 3.2 2011-07-22 11:10:43 -05:00