Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

[DO NOT MERGE] Fix def line numbers for decorated nodes #61

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ parsers. `typed_ast` runs on Python 3.3-3.6 on Linux, OS X and Windows.

## Development Philosophy

This project is a 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
additional optional arguments to the `parse` call. From time to time we may backport important bug fixes from upstream. Therefore, `typed_ast` will
ethanhs marked this conversation as resolved.
Show resolved Hide resolved
not accept most all 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
ethanhs marked this conversation as resolved.
Show resolved Hide resolved
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.

Expand Down
6 changes: 0 additions & 6 deletions ast27/Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 0 additions & 6 deletions ast3/Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1828,12 +1828,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;
}

Expand Down
2 changes: 2 additions & 0 deletions typed_ast/ast27.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions typed_ast/ast3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down