summaryrefslogtreecommitdiff
path: root/Python/compile.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-10 14:44:43 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-10 14:44:43 +0200
commit7510c5a18710c48769e9cffb481c00bbd6261124 (patch)
tree89f8d7b2950923a9f2842ce6c179dff7a98e981a /Python/compile.c
parente8844f1a723c551e175e90d5ee7d26a874005ab0 (diff)
parente1d7d40b253055b0e82f0df427c08566fd44beac (diff)
downloadcpython-7510c5a18710c48769e9cffb481c00bbd6261124.tar.gz
Fix a test for SpooledTemporaryFile (added in issue #10355).
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 3cf71ef09e..8f876a6d0d 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -2635,6 +2635,10 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
if (!mangled)
return 0;
+ assert(PyUnicode_CompareWithASCIIString(name, "None") &&
+ PyUnicode_CompareWithASCIIString(name, "True") &&
+ PyUnicode_CompareWithASCIIString(name, "False"));
+
op = 0;
optype = OP_NAME;
scope = PyST_GetScope(c->u->u_ste, mangled);
@@ -3194,12 +3198,18 @@ expr_constant(struct compiler *c, expr_ty e)
case Name_kind:
/* optimize away names that can't be reassigned */
id = PyUnicode_AsUTF8(e->v.Name.id);
- if (strcmp(id, "True") == 0) return 1;
- if (strcmp(id, "False") == 0) return 0;
- if (strcmp(id, "None") == 0) return 0;
- if (strcmp(id, "__debug__") == 0)
- return ! c->c_optimize;
- /* fall through */
+ if (id && strcmp(id, "__debug__") == 0)
+ return !c->c_optimize;
+ return -1;
+ case NameConstant_kind: {
+ PyObject *o = e->v.NameConstant.value;
+ if (o == Py_None)
+ return 0;
+ else if (o == Py_True)
+ return 1;
+ else if (o == Py_False)
+ return 0;
+ }
default:
return -1;
}
@@ -3375,6 +3385,9 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
case Ellipsis_kind:
ADDOP_O(c, LOAD_CONST, Py_Ellipsis, consts);
break;
+ case NameConstant_kind:
+ ADDOP_O(c, LOAD_CONST, e->v.NameConstant.value, consts);
+ break;
/* The following exprs can be assignment targets. */
case Attribute_kind:
if (e->v.Attribute.ctx != AugStore)