Author: Antonio Cuni <[email protected]>
Branch:
Changeset: r58177:b1a5512d3fbb
Date: 2012-10-17 17:15 +0200
http://bitbucket.org/pypy/pypy/changeset/b1a5512d3fbb/
Log: bah, our old value for CO_CONTAINSGLOBAL conflicts with
PyCF_IGNORE_COOKIE. Add a test to check that we don't have duplicate
flags, fix the value of CO_CONTAINSGLOBAL and remove a magic number
from test_code_extra, which now passes
diff --git a/pypy/interpreter/astcompiler/consts.py
b/pypy/interpreter/astcompiler/consts.py
--- a/pypy/interpreter/astcompiler/consts.py
+++ b/pypy/interpreter/astcompiler/consts.py
@@ -9,13 +9,14 @@
CO_NESTED = 0x0010
CO_GENERATOR = 0x0020
CO_NOFREE = 0x0040
-CO_CONTAINSGLOBALS = 0x0800
CO_GENERATOR_ALLOWED = 0x1000
CO_FUTURE_DIVISION = 0x2000
CO_FUTURE_ABSOLUTE_IMPORT = 0x4000
CO_FUTURE_WITH_STATEMENT = 0x8000
CO_FUTURE_PRINT_FUNCTION = 0x10000
CO_FUTURE_UNICODE_LITERALS = 0x20000
+CO_CONTAINSGLOBALS = 0x80000 # pypy-specific: need to check that it's not used
+ # by any other flag
PyCF_SOURCE_IS_UTF8 = 0x0100
PyCF_DONT_IMPLY_DEDENT = 0x0200
diff --git a/pypy/interpreter/test/test_code.py
b/pypy/interpreter/test/test_code.py
--- a/pypy/interpreter/test/test_code.py
+++ b/pypy/interpreter/test/test_code.py
@@ -1,5 +1,6 @@
from pypy.conftest import gettestobjspace
from pypy.interpreter import gateway
+from pypy.interpreter.astcompiler import consts
import py
class AppTestCodeIntrospection:
@@ -11,6 +12,7 @@
filename = filename[:-1]
cls.w_file = space.wrap(filename)
+ cls.w_CO_CONTAINSGLOBALS = space.wrap(consts.CO_CONTAINSGLOBALS)
def test_attributes(self):
def f(): pass
@@ -185,7 +187,7 @@
assert f(4).func_code.co_flags & 0x10
assert f.func_code.co_flags & 0x10 == 0
# check for CO_CONTAINSGLOBALS
- assert not f.func_code.co_flags & 0x0800
+ assert not f.func_code.co_flags & self.CO_CONTAINSGLOBALS
exec """if 1:
@@ -197,8 +199,8 @@
"""
# check for CO_CONTAINSGLOBALS
- assert f.func_code.co_flags & 0x0800
- assert not g.func_code.co_flags & 0x0800
+ assert f.func_code.co_flags & self.CO_CONTAINSGLOBALS
+ assert not g.func_code.co_flags & self.CO_CONTAINSGLOBALS
exec """if 1:
b = 2
@@ -207,4 +209,4 @@
return a + b + x
"""
# check for CO_CONTAINSGLOBALS
- assert f.func_code.co_flags & 0x0800
+ assert f.func_code.co_flags & self.CO_CONTAINSGLOBALS
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit