mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
check by equality for __future__ not identity (closes #14378)
This commit is contained in:
parent
e112153727
commit
a4e4e35783
3 changed files with 11 additions and 8 deletions
|
@ -60,13 +60,6 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename)
|
|||
{
|
||||
int i, found_docstring = 0, done = 0, prev_line = 0;
|
||||
|
||||
static PyObject *future;
|
||||
if (!future) {
|
||||
future = PyUnicode_InternFromString("__future__");
|
||||
if (!future)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(mod->kind == Module_kind || mod->kind == Interactive_kind))
|
||||
return 1;
|
||||
|
||||
|
@ -93,7 +86,8 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename)
|
|||
*/
|
||||
|
||||
if (s->kind == ImportFrom_kind) {
|
||||
if (s->v.ImportFrom.module == future) {
|
||||
PyObject *modname = s->v.ImportFrom.module;
|
||||
if (!PyUnicode_CompareWithASCIIString(modname, "__future__")) {
|
||||
if (done) {
|
||||
PyErr_SetString(PyExc_SyntaxError,
|
||||
ERR_LATE_FUTURE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue