mirror of
https://github.com/python/cpython.git
synced 2025-09-11 11:17:16 +00:00
Patch from Georg Brandl: Fix co_lineno of decorated function and class objects. If you see an error in test_inspect please delete all pyc files.
This commit is contained in:
parent
90c3d9b995
commit
09aaa88328
3 changed files with 9 additions and 1 deletions
|
@ -239,7 +239,7 @@ class TestDecorators(GetSourceBase):
|
||||||
fodderFile = mod2
|
fodderFile = mod2
|
||||||
|
|
||||||
def test_wrapped_decorator(self):
|
def test_wrapped_decorator(self):
|
||||||
self.assertSourceEqual(mod2.wrapped, 16, 17)
|
self.assertSourceEqual(mod2.wrapped, 14, 17)
|
||||||
|
|
||||||
def test_replacing_decorator(self):
|
def test_replacing_decorator(self):
|
||||||
self.assertSourceEqual(mod2.gone, 9, 10)
|
self.assertSourceEqual(mod2.gone, 9, 10)
|
||||||
|
|
|
@ -363,6 +363,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- inspect.getsource() includes the decorators again.
|
||||||
|
|
||||||
- Issue #1916. Added isgenerator() and isgeneratorfunction() to inspect.py.
|
- Issue #1916. Added isgenerator() and isgeneratorfunction() to inspect.py.
|
||||||
|
|
||||||
- #1224: Fixed bad url parsing when path begins with double slash.
|
- #1224: Fixed bad url parsing when path begins with double slash.
|
||||||
|
|
|
@ -1015,6 +1015,12 @@ ast_for_decorated(struct compiling *c, const node *n)
|
||||||
} else if (TYPE(CHILD(n, 1)) == classdef) {
|
} else if (TYPE(CHILD(n, 1)) == classdef) {
|
||||||
thing = ast_for_classdef(c, CHILD(n, 1), decorator_seq);
|
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;
|
return thing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue