From 7a47e4135954f91feb742530ebf6a0db0e80ef41 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 22 Mar 2012 08:19:04 -0400 Subject: check by equality for __future__ not identity (closes #14378) --- Python/future.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'Python/future.c') diff --git a/Python/future.c b/Python/future.c index d6b653f315..978dc25306 100644 --- a/Python/future.c +++ b/Python/future.c @@ -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); -- cgit v1.2.1 From 474fb69283735e7d444cf26eb29306e9e7d2fb93 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 22 Mar 2012 08:56:15 -0400 Subject: check for NULL --- Python/future.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Python/future.c') diff --git a/Python/future.c b/Python/future.c index 978dc25306..89592e2224 100644 --- a/Python/future.c +++ b/Python/future.c @@ -87,7 +87,8 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename) if (s->kind == ImportFrom_kind) { PyObject *modname = s->v.ImportFrom.module; - if (!PyUnicode_CompareWithASCIIString(modname, "__future__")) { + if (modname && + !PyUnicode_CompareWithASCIIString(modname, "__future__")) { if (done) { PyErr_SetString(PyExc_SyntaxError, ERR_LATE_FUTURE); -- cgit v1.2.1 From df18e7a8d30d850784dec55a36bb75c4775f0344 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Thu, 22 Mar 2012 10:39:16 -0400 Subject: this should technicaly be identifier --- Python/future.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/future.c') diff --git a/Python/future.c b/Python/future.c index 89592e2224..83465a8710 100644 --- a/Python/future.c +++ b/Python/future.c @@ -86,7 +86,7 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename) */ if (s->kind == ImportFrom_kind) { - PyObject *modname = s->v.ImportFrom.module; + identifier *modname = s->v.ImportFrom.module; if (modname && !PyUnicode_CompareWithASCIIString(modname, "__future__")) { if (done) { -- cgit v1.2.1 From f84f102a23067e752b800f498f4260135094b679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Fri, 23 Mar 2012 12:50:53 +0000 Subject: Fix typo when "PyObject*" was changed to "identifier" --- Python/future.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/future.c') diff --git a/Python/future.c b/Python/future.c index 83465a8710..d24ae416ff 100644 --- a/Python/future.c +++ b/Python/future.c @@ -86,7 +86,7 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename) */ if (s->kind == ImportFrom_kind) { - identifier *modname = s->v.ImportFrom.module; + identifier modname = s->v.ImportFrom.module; if (modname && !PyUnicode_CompareWithASCIIString(modname, "__future__")) { if (done) { -- cgit v1.2.1