diff --git a/README.md b/README.md index 2a50ea39..f10056d1 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,17 @@ parsers. `typed_ast` runs on Python 3.3-3.7 on Linux, OS X and Windows. ## Development Philosophy -This project is a (mostly) drop-in replacement for the builtin `ast` module. It is +This project is a near drop-in replacement for the builtin `ast` module. It is intended to be bug-for-bug compatible and behave identically, except for the presence of a few additional fields on the returned classes and a few -additional optional arguments to the `parse` call. Therefore, `typed_ast` will -not accept any bugfixes for bugs in `ast` -- they should be fixed upstream -instead. To avoid feature bloat, any new features for `typed_ast` should have -the potential to be broadly useful and not be built just for one niche usecase -or in a manner such that only one project can use them. +additional optional arguments to the `parse` call. From time to time we may +backport important bug fixes from upstream. Therefore, `typed_ast` will not +accept most bugfixes for bugs in `ast`. Before a bug fix is considered, it +must be merged upstream first. In other words, we only will take select +backports from the upstream ast module. To avoid feature bloat, any new +features for `typed_ast` should have the potential to be broadly useful and not +be built just for one niche usecase or in a manner such that only one project +can use them. ### Incompatabilities @@ -40,11 +43,11 @@ not treated as keywords. The `ast3` parser produces the AST from a recent version of Python 3 (currently Python 3.6). When new versions of Python 3 are released, it will be updated to match any changes in their AST. (For rationale and technical -details, see [here](update_process.md).) The AST it currently produces is described in -[ast3/Parser/Python.asdl](ast3/Parser/Python.asdl). If you wish to limit -parsing to older versions of Python 3, `ast3` can be configured to to give a -SyntaxError for new syntax features introduced beyond a given Python version. -For more information, see the module docstring in +details, see [here](update_process.md).) The AST it currently produces is +described in [ast3/Parser/Python.asdl](ast3/Parser/Python.asdl). If you wish +to limit parsing to older versions of Python 3, `ast3` can be configured to to +give a SyntaxError for new syntax features introduced beyond a given Python +version. For more information, see the module docstring in [typed\_ast/ast3.py](typed_ast/ast3.py). ### ast27 @@ -64,6 +67,8 @@ Note: as these parsers consider type comments part of the grammar, incorrectly placed type comments are considered syntax errors. ## Updates and Releases -To update `typed_ast` for new major Python releases, see [`update_process.md`](update_process.md). +To update `typed_ast` for new major Python releases, see +[`update_process.md`](update_process.md). -To make a new `typed_ast` release, see [`release_process.md`](release_process.md). +To make a new `typed_ast` release, see +[`release_process.md`](release_process.md). diff --git a/ast27/Python/ast.c b/ast27/Python/ast.c index 4184639c..702d6a76 100644 --- a/ast27/Python/ast.c +++ b/ast27/Python/ast.c @@ -1061,12 +1061,6 @@ ast_for_decorated(struct compiling *c, const node *n) } else if (TYPE(CHILD(n, 1)) == classdef) { thing = ast_for_classdef(c, CHILD(n, 1), decorator_seq); } - /* we count the decorators in when talking about the class' or - function's line number */ - if (thing) { - thing->lineno = LINENO(n); - thing->col_offset = n->n_col_offset; - } return thing; } diff --git a/ast3/Python/ast.c b/ast3/Python/ast.c index 99a059a4..08e7c8e5 100644 --- a/ast3/Python/ast.c +++ b/ast3/Python/ast.c @@ -1879,12 +1879,6 @@ ast_for_decorated(struct compiling *c, const node *n) } else if (TYPE(CHILD(n, 1)) == async_funcdef) { thing = ast_for_async_funcdef(c, CHILD(n, 1), decorator_seq); } - /* we count the decorators in when talking about the class' or - * function's line number */ - if (thing) { - thing->lineno = LINENO(n); - thing->col_offset = n->n_col_offset; - } return thing; } diff --git a/typed_ast/ast27.py b/typed_ast/ast27.py index e11ebc20..227b4fac 100644 --- a/typed_ast/ast27.py +++ b/typed_ast/ast27.py @@ -21,6 +21,8 @@ lines which have been `# type: ignore`d. - `Str` has a `kind` string field which preserves the original string prefix, so that `ast27.parse('br"test"').body[0].value.kind == 'br'`. + - Fixed line number information for decorated AST nodes. + (Based on https://github.com/python/cpython/pull/9731) An abstract syntax tree can be generated by using the `parse()` function from this module. The result will be a tree of objects whose diff --git a/typed_ast/ast3.py b/typed_ast/ast3.py index 9b972355..1e3840f8 100644 --- a/typed_ast/ast3.py +++ b/typed_ast/ast3.py @@ -23,6 +23,8 @@ lines which have been `# type: ignore`d. - `Str` has a `kind` string field which preserves the original string prefix, so that `ast3.parse('u"test"').body[0].value.kind == 'u'`. + - Fixed line number information for decorated AST nodes. + (Based on https://github.com/python/cpython/pull/9731) An abstract syntax tree can be generated by using the `parse()` function from this module. The result will be a tree of objects whose