[New-bugs-announce] [issue24049] Remove unused code in symtable.c and fix docs for import * checking

Nick Craig-Wood report at bugs.python.org
Fri Apr 24 14:36:02 CEST 2015


New submission from Nick Craig-Wood:

Here is a patch to remove some unused code in `symtable.c`

In Python3 `from x import *` was banned from use in functions completely.

This is detected by `symtable_visit_alias` 

        if (st->st_cur->ste_type != ModuleBlock) {
            int lineno = st->st_cur->ste_lineno;
            int col_offset = st->st_cur->ste_col_offset;
            PyErr_SetString(PyExc_SyntaxError, IMPORT_STAR_WARNING);

However in `check_unoptimized` it checks for `import *` being used in a nested function etc.  This is the python2 behaviour which wasn't removed at the time the new python3 behaviour was added.

According to my analysis and tests it is now impossible for `check_unoptimized` to raise an error, since only valid uses of `import *` are left at the point it is called.

I propose to remove that function entirely, its call, and fix some stray documentation in this patch.

----------
components: Interpreter Core
files: python3.5-symtable.patch
keywords: patch
messages: 241937
nosy: ncw
priority: normal
severity: normal
status: open
title: Remove unused code in symtable.c and fix docs for import * checking
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file39195/python3.5-symtable.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24049>
_______________________________________


More information about the New-bugs-announce mailing list