mirror of
https://github.com/python/cpython.git
synced 2025-08-26 03:34:43 +00:00
bpo-38605: Revert making 'from __future__ import annotations' the default (GH-25490)
This reverts commits044a1048ca
and1be456ae9d
, adapting the code to changes that happened after it.
This commit is contained in:
parent
d35eef3b90
commit
b0544ba77c
32 changed files with 436 additions and 523 deletions
|
@ -2111,16 +2111,24 @@ static int
|
|||
compiler_visit_argannotation(struct compiler *c, identifier id,
|
||||
expr_ty annotation, Py_ssize_t *annotations_len)
|
||||
{
|
||||
if (annotation) {
|
||||
PyObject *mangled = _Py_Mangle(c->u->u_private, id);
|
||||
if (!mangled)
|
||||
return 0;
|
||||
|
||||
ADDOP_LOAD_CONST(c, mangled);
|
||||
Py_DECREF(mangled);
|
||||
VISIT(c, annexpr, annotation);
|
||||
*annotations_len += 2;
|
||||
if (!annotation) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
PyObject *mangled = _Py_Mangle(c->u->u_private, id);
|
||||
if (!mangled) {
|
||||
return 0;
|
||||
}
|
||||
ADDOP_LOAD_CONST(c, mangled);
|
||||
Py_DECREF(mangled);
|
||||
|
||||
if (c->c_future->ff_features & CO_FUTURE_ANNOTATIONS) {
|
||||
VISIT(c, annexpr, annotation)
|
||||
}
|
||||
else {
|
||||
VISIT(c, expr, annotation);
|
||||
}
|
||||
*annotations_len += 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -5403,7 +5411,12 @@ compiler_annassign(struct compiler *c, stmt_ty s)
|
|||
if (s->v.AnnAssign.simple &&
|
||||
(c->u->u_scope_type == COMPILER_SCOPE_MODULE ||
|
||||
c->u->u_scope_type == COMPILER_SCOPE_CLASS)) {
|
||||
VISIT(c, annexpr, s->v.AnnAssign.annotation);
|
||||
if (c->c_future->ff_features & CO_FUTURE_ANNOTATIONS) {
|
||||
VISIT(c, annexpr, s->v.AnnAssign.annotation)
|
||||
}
|
||||
else {
|
||||
VISIT(c, expr, s->v.AnnAssign.annotation);
|
||||
}
|
||||
ADDOP_NAME(c, LOAD_NAME, __annotations__, names);
|
||||
mangled = _Py_Mangle(c->u->u_private, targ->v.Name.id);
|
||||
ADDOP_LOAD_CONST_NEW(c, mangled);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue