summaryrefslogtreecommitdiffstats
path: root/Modules/parsermodule.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-35766: Merge typed_ast back into CPython (GH-11645)Guido van Rossum2019-01-311-0/+6
|
* bpo-33416: Add end positions to Python AST (GH-11605)Ivan Levkivskyi2019-01-221-1/+1
| | | | | | | | | | | | | | | | | | The majority of this PR is tediously passing `end_lineno` and `end_col_offset` everywhere. Here are non-trivial points: * It is not possible to reconstruct end positions in AST "on the fly", some information is lost after an AST node is constructed, so we need two more attributes for every AST node `end_lineno` and `end_col_offset`. * I add end position information to both CST and AST. Although it may be technically possible to avoid adding end positions to CST, the code becomes more cumbersome and less efficient. * Since the end position is not known for non-leaf CST nodes while the next token is added, this requires a bit of extra care (see `_PyNode_FinalizeEndPos`). Unless I made some mistake, the algorithm should be linear. * For statements, I "trim" the end position of suites to not include the terminal newlines and dedent (this seems to be what people would expect), for example in ```python class C: pass pass ``` the end line and end column for the class definition is (2, 8). * For `end_col_offset` I use the common Python convention for indexing, for example for `pass` the `end_col_offset` is 4 (not 3), so that `[0:4]` gives one the source code that corresponds to the node. * I added a helper function `ast.get_source_segment()`, to get source text segment corresponding to a given AST node. It is also useful for testing. An (inevitable) downside of this PR is that AST now takes almost 25% more memory. I think however it is probably justified by the benefits.
* bpo-33012: Fix invalid function cast warnings with gcc 8. (GH-6749)Serhiy Storchaka2018-11-271-14/+14
| | | | | | Fix invalid function cast warnings with gcc 8 for method conventions different from METH_NOARGS, METH_O and METH_VARARGS excluding Argument Clinic generated code.
* 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
* bpo-35177: Add dependencies between header files (GH-10361)Victor Stinner2018-11-111-3/+2
| | | | | | | | | | | | | | * 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-33308: Fix a crash in the parser module when convert an ST object. (#6519)Serhiy Storchaka2018-04-181-3/+3
| | | | Converting with line_info=False and col_info=True crashed before.
* bpo-23699: Use a macro to reduce boilerplate code in rich comparison ↵stratakis2017-11-021-32/+2
| | | | functions (GH-793)
* bpo-30070: Fixed leaks and crashes in errors handling in the parser module. ↵Serhiy Storchaka2017-04-191-52/+79
| | | | (#1131)
* Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE whereverSerhiy Storchaka2017-01-231-2/+1
| | | | possible. Patch is writen with Coccinelle.
* Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSizeSerhiy Storchaka2016-11-201-2/+2
| | | | with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
* replace custom validation logic in the parse module with a simple DFA ↵Benjamin Peterson2016-06-021-2452/+93
| | | | | | validator (closes #26526) Patch from A. Skrobov.
* Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka2015-12-251-5/+5
| | | | private functions.
* Issue #25923: Added the const qualifier to static constant arrays.Serhiy Storchaka2015-12-251-2/+2
|
* Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.Serhiy Storchaka2015-12-191-1/+1
| | | | | This allows sys.getsize() to work correctly with their subclasses with __slots__ defined.
* Issue #24791: Fix grammar regression for call syntax: 'g(*a or b)'.Yury Selivanov2015-08-051-3/+6
|
* allow test node after ** in calls (closes #24176)Benjamin Peterson2015-05-161-1/+1
|
* PEP 0492 -- Coroutines with async and await syntax. Issue #24017.Yury Selivanov2015-05-121-12/+103
|
* PEP 448: additional unpacking generalizations (closes #2292)Benjamin Peterson2015-05-061-124/+141
| | | | Patch by Neil Girdhar.
* Removed unintentional trailing spaces in non-external and non-generated C files.Serhiy Storchaka2015-03-181-1/+1
|
* (Merge 3.3) parser: fix usage of Py_BuildValue() to build a parser errorVictor Stinner2014-01-021-1/+1
|\ | | | | | | Fix typo: "os" format => "Os"
| * parser: fix usage of Py_BuildValue() to build a parser errorVictor Stinner2014-01-021-1/+1
| | | | | | | | Fix typo: "os" format => "Os"
| * Issue #15989: Fix several occurrences of integer overflowSerhiy Storchaka2013-01-191-5/+19
| |\ | | | | | | | | | | | | | | | when result of PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277.
* | | Close #11619: The parser and the import machinery do not encode UnicodeVictor Stinner2013-08-261-18/+31
| | | | | | | | | | | | filenames anymore on Windows.
* | | Issue #18408: Fix typo in build_node_tree() of the parser moduleVictor Stinner2013-07-161-1/+1
| | | | | | | | | | | | Type "o" format of Py_BuildValue() is invalid: it must be "O".
* | | Issue #18408: parser module: fix error handling in node2tuple()Victor Stinner2013-07-111-28/+52
| | | | | | | | | | | | Handle PyLong_FromLong() and PyUnicode_FromString() failures
* | | Issue #18408: Fix parser.sequence2st() and parser.tuple2st(): raise MemoryErrorVictor Stinner2013-07-111-4/+15
| | | | | | | | | | | | | | | | | | on memory allocation failure Instead of ignoring the memory allocation failure and create invalid objects.
* | | Issue #15989: Fix several occurrences of integer overflowSerhiy Storchaka2013-01-141-5/+19
|/ / | | | | | | when result of PyLong_AsLong() narrowed to int without checks.
* | Issue #16714: use 'raise' exceptions, don't 'throw'.Andrew Svetlov2012-12-181-3/+3
|\ \ | |/ | | | | Patch by Serhiy Storchaka.
| * Issue #16714: use 'raise' exceptions, don't 'throw'.Andrew Svetlov2012-12-181-3/+3
| | | | | | | | Patch by Serhiy Storchaka.
* | Issue #15604: Update uses of PyObject_IsTrue() to check for and handle ↵Antoine Pitrou2012-08-151-32/+16
|\ \ | |/ | | | | | | | | errors correctly. Patch by Serhiy Storchaka.
| * Issue #15604: Update uses of PyObject_IsTrue() to check for and handle ↵Antoine Pitrou2012-08-151-5/+13
| | | | | | | | | | | | errors correctly. Patch by Serhiy Storchaka.
* | MERGE: Closes #15512: Correct __sizeof__ support for parserJesus Cea2012-08-031-1/+12
|\ \ | |/
| * Closes #15512: Correct __sizeof__ support for parserJesus Cea2012-08-031-1/+12
| |
* | Issue #14741: Merge fix from 3.2.Mark Dickinson2012-05-071-5/+1
|\ \ | |/
| * Issue #14741: Fix missing support for ellipsis in parser module.Mark Dickinson2012-05-071-5/+1
| |
* | Issue #14697: Merge fix from 3.2.Mark Dickinson2012-05-071-21/+79
|\ \ | |/
| * Issue #14697: Fix missing parser module support for set displays and set ↵Mark Dickinson2012-05-071-21/+79
| | | | | | | | comprehensions.
* | Issue #14701: Merge fix from 3.2.Mark Dickinson2012-05-071-12/+11
|\ \ | |/
| * Issue #14701: Add missing support for 'raise ... from' in parser module.Mark Dickinson2012-05-071-12/+11
| |
* | Issue #14696: Merge from 3.2Mark Dickinson2012-04-291-5/+36
|\ \ | |/
| * Issue #14696: Fix parser module to understand 'nonlocal' declarations.Mark Dickinson2012-04-291-5/+36
| |
* | Issue #9154: Merge fix from 3.2.Mark Dickinson2012-04-291-57/+71
|\ \ | |/
| * Issue #9154: Fix parser module to understand function annotations.Mark Dickinson2012-04-291-57/+71
| |
* | Implement PEP 380 - 'yield from' (closes #11682)Nick Coghlan2012-01-131-27/+55
| |
* | Rename _Py_identifier to _Py_IDENTIFIER.Martin v. Löwis2011-10-141-3/+3
| |
* | Use identifier API for PyObject_GetAttrString.Martin v. Löwis2011-10-101-3/+6
| |
* | always clear parser errorBenjamin Peterson2011-06-061-1/+1
| |
* | only clear the parser error if it's set (closes #12264)Benjamin Peterson2011-06-051-2/+3
| |
* | Issue #10785: Store the filename as Unicode in the Python parser.Victor Stinner2011-04-041-0/+1
|/
* #11515: Merge with 3.1.Ezio Melotti2011-03-151-1/+1
|\