Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9bdd613

Browse files
committed
remove dead *-import checking code (closes python#24049)
1 parent bd91ee9 commit 9bdd613

2 files changed

Lines changed: 0 additions & 35 deletions

File tree

Doc/reference/executionmodel.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,6 @@ conjunction with nested scopes that contain free variables.
161161
If a variable is referenced in an enclosing scope, it is illegal to delete the
162162
name. An error will be reported at compile time.
163163

164-
If the wild card form of import --- ``import *`` --- is used in a function and
165-
the function contains or is a nested block with free variables, the compiler
166-
will raise a :exc:`SyntaxError`.
167-
168164
.. XXX from * also invalid with relative imports (at least currently)
169165
170166
The :func:`eval` and :func:`exec` functions do not have access to the full

Python/symtable.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -583,35 +583,6 @@ drop_class_free(PySTEntryObject *ste, PyObject *free)
583583
return 1;
584584
}
585585

586-
/* Check for illegal statements in unoptimized namespaces */
587-
static int
588-
check_unoptimized(const PySTEntryObject* ste) {
589-
const char* trailer;
590-
591-
if (ste->ste_type != FunctionBlock || !ste->ste_unoptimized
592-
|| !(ste->ste_free || ste->ste_child_free))
593-
return 1;
594-
595-
trailer = (ste->ste_child_free ?
596-
"contains a nested function with free variables" :
597-
"is a nested function");
598-
599-
switch (ste->ste_unoptimized) {
600-
case OPT_TOPLEVEL: /* import * at top-level is fine */
601-
return 1;
602-
case OPT_IMPORT_STAR:
603-
PyErr_Format(PyExc_SyntaxError,
604-
"import * is not allowed in function '%U' because it %s",
605-
ste->ste_name, trailer);
606-
break;
607-
}
608-
609-
PyErr_SyntaxLocationObject(ste->ste_table->st_filename,
610-
ste->ste_opt_lineno,
611-
ste->ste_opt_col_offset);
612-
return 0;
613-
}
614-
615586
/* Enter the final scope information into the ste_symbols dict.
616587
*
617588
* All arguments are dicts. Modifies symbols, others are read-only.
@@ -854,8 +825,6 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free,
854825
if (!update_symbols(ste->ste_symbols, scopes, bound, newfree,
855826
ste->ste_type == ClassBlock))
856827
goto error;
857-
if (!check_unoptimized(ste))
858-
goto error;
859828

860829
temp = PyNumber_InPlaceOr(free, newfree);
861830
if (!temp)

0 commit comments

Comments
 (0)