[pypy-commit] pypy py3.3: Fix for cpython Issue #17983
amauryfa
noreply at buildbot.pypy.org
Thu Jul 3 23:58:22 CEST 2014
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3.3
Changeset: r72349:37095df3c8ad
Date: 2014-07-03 23:51 +0200
http://bitbucket.org/pypy/pypy/changeset/37095df3c8ad/
Log: Fix for cpython Issue #17983
diff --git a/pypy/interpreter/astcompiler/symtable.py b/pypy/interpreter/astcompiler/symtable.py
--- a/pypy/interpreter/astcompiler/symtable.py
+++ b/pypy/interpreter/astcompiler/symtable.py
@@ -437,6 +437,9 @@
def visit_Global(self, glob):
for name in glob.names:
+ if isinstance(self.scope, ClassScope) and name == '__class__':
+ raise SyntaxError("cannot make __class__ global",
+ glob.lineno, glob.col_offset)
old_role = self.scope.lookup_role(name)
if old_role & (SYM_USED | SYM_ASSIGNED):
if old_role & SYM_ASSIGNED:
diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py
--- a/pypy/interpreter/astcompiler/test/test_compiler.py
+++ b/pypy/interpreter/astcompiler/test/test_compiler.py
@@ -974,6 +974,15 @@
"""
yield self.st, test, "g()", range(3)
+ def test__class__global(self):
+ source = """if 1:
+ class X:
+ global __class__
+ def f(self):
+ super()
+ """
+ py.test.raises(SyntaxError, self.simple_test, source, None, None)
+
class AppTestCompiler:
More information about the pypy-commit
mailing list