Antonio Cuni avatar Antonio Cuni committed b1a5512

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

Comments (0)

Files changed (2)

pypy/interpreter/astcompiler/consts.py

 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

pypy/interpreter/test/test_code.py

 from pypy.conftest import gettestobjspace
 from pypy.interpreter import gateway
+from pypy.interpreter.astcompiler import consts
 import py
 
 class AppTestCodeIntrospection:
             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
         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:
 """
 
         # 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
             return a + b + x
 """
         # check for CO_CONTAINSGLOBALS
-        assert f.func_code.co_flags & 0x0800
+        assert f.func_code.co_flags & self.CO_CONTAINSGLOBALS
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.