mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
gh-126072: do not add None
to co_consts
if there is no docstring (GH-126101)
This commit is contained in:
parent
2ab377a47c
commit
35df4eb959
16 changed files with 148 additions and 58 deletions
|
@ -136,6 +136,8 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block,
|
|||
ste->ste_needs_classdict = 0;
|
||||
ste->ste_annotation_block = NULL;
|
||||
|
||||
ste->ste_has_docstring = 0;
|
||||
|
||||
ste->ste_symbols = PyDict_New();
|
||||
ste->ste_varnames = PyList_New(0);
|
||||
ste->ste_children = PyList_New(0);
|
||||
|
@ -1841,6 +1843,10 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (_PyAST_GetDocString(s->v.FunctionDef.body)) {
|
||||
new_ste->ste_has_docstring = 1;
|
||||
}
|
||||
|
||||
if (!symtable_visit_annotations(st, s, s->v.FunctionDef.args,
|
||||
s->v.FunctionDef.returns, new_ste)) {
|
||||
Py_DECREF(new_ste);
|
||||
|
@ -2168,6 +2174,10 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (_PyAST_GetDocString(s->v.AsyncFunctionDef.body)) {
|
||||
new_ste->ste_has_docstring = 1;
|
||||
}
|
||||
|
||||
if (!symtable_visit_annotations(st, s, s->v.AsyncFunctionDef.args,
|
||||
s->v.AsyncFunctionDef.returns, new_ste)) {
|
||||
Py_DECREF(new_ste);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue