mirror of https://github.com/python/cpython.git
bpo-46331: Do not set line number of instruction storing doc-string. (GH-30518)
This commit is contained in:
parent
ea1a54506b
commit
bd04fac7eb
|
@ -1403,6 +1403,25 @@ def func():
|
||||||
(3, 'line'),
|
(3, 'line'),
|
||||||
(3, 'return')])
|
(3, 'return')])
|
||||||
|
|
||||||
|
def test_class_creation_with_docstrings(self):
|
||||||
|
|
||||||
|
def func():
|
||||||
|
class Class_1:
|
||||||
|
''' the docstring. 2'''
|
||||||
|
def __init__(self):
|
||||||
|
''' Another docstring. 4'''
|
||||||
|
self.a = 5
|
||||||
|
|
||||||
|
self.run_and_compare(func,
|
||||||
|
[(0, 'call'),
|
||||||
|
(1, 'line'),
|
||||||
|
(1, 'call'),
|
||||||
|
(1, 'line'),
|
||||||
|
(2, 'line'),
|
||||||
|
(3, 'line'),
|
||||||
|
(3, 'return'),
|
||||||
|
(1, 'return')])
|
||||||
|
|
||||||
|
|
||||||
class SkipLineEventsTraceTestCase(TraceTestCase):
|
class SkipLineEventsTraceTestCase(TraceTestCase):
|
||||||
"""Repeat the trace tests, but with per-line events skipped"""
|
"""Repeat the trace tests, but with per-line events skipped"""
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Do not set line number of instruction storing doc-string. Fixes regression
|
||||||
|
introduced in 3.11 alpha.
|
|
@ -2034,6 +2034,7 @@ compiler_body(struct compiler *c, asdl_stmt_seq *stmts)
|
||||||
st = (stmt_ty)asdl_seq_GET(stmts, 0);
|
st = (stmt_ty)asdl_seq_GET(stmts, 0);
|
||||||
assert(st->kind == Expr_kind);
|
assert(st->kind == Expr_kind);
|
||||||
VISIT(c, expr, st->v.Expr.value);
|
VISIT(c, expr, st->v.Expr.value);
|
||||||
|
UNSET_LOC(c);
|
||||||
if (!compiler_nameop(c, __doc__, Store))
|
if (!compiler_nameop(c, __doc__, Store))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue