[pypy-commit] pypy default: Kill CO_CONTAINSGLOBALS, which was used by celldict.py but no longer is.
arigo
noreply at buildbot.pypy.org
Fri Apr 26 10:56:58 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r63632:f48d790fc17b
Date: 2013-04-26 10:56 +0200
http://bitbucket.org/pypy/pypy/changeset/f48d790fc17b/
Log: Kill CO_CONTAINSGLOBALS, which was used by celldict.py but no longer
is.
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
@@ -15,8 +15,6 @@
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/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -12,7 +12,7 @@
from pypy.interpreter.gateway import unwrap_spec
from pypy.interpreter.astcompiler.consts import (
CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS, CO_NESTED,
- CO_GENERATOR, CO_CONTAINSGLOBALS)
+ CO_GENERATOR)
from pypy.tool.stdlib_opcode import opcodedesc, HAVE_ARGUMENT
from rpython.rlib.rarithmetic import intmask
from rpython.rlib.objectmodel import compute_hash
@@ -88,8 +88,6 @@
self._initialize()
def _initialize(self):
- self._init_flags()
-
if self.co_cellvars:
argcount = self.co_argcount
assert argcount >= 0 # annotator hint
@@ -134,22 +132,6 @@
'__pypy__' not in sys.builtin_module_names):
raise Exception("CPython host codes should not be rendered")
- def _init_flags(self):
- co_code = self.co_code
- next_instr = 0
- while next_instr < len(co_code):
- opcode = ord(co_code[next_instr])
- next_instr += 1
- if opcode >= HAVE_ARGUMENT:
- next_instr += 2
- while opcode == opcodedesc.EXTENDED_ARG.index:
- opcode = ord(co_code[next_instr])
- next_instr += 3
- if opcode == opcodedesc.LOAD_GLOBAL.index:
- self.co_flags |= CO_CONTAINSGLOBALS
- elif opcode == opcodedesc.LOAD_NAME.index:
- self.co_flags |= CO_CONTAINSGLOBALS
-
co_names = property(lambda self: [self.space.unwrap(w_name) for w_name in self.co_names_w]) # for trace
def signature(self):
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
@@ -9,7 +9,6 @@
filename = filename[:-1]
cls.w_file = cls.space.wrap(filename)
- cls.w_CO_CONTAINSGLOBALS = cls.space.wrap(consts.CO_CONTAINSGLOBALS)
def test_attributes(self):
def f(): pass
@@ -183,27 +182,3 @@
# CO_NESTED
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 & self.CO_CONTAINSGLOBALS
-
-
- exec """if 1:
- r = range
- def f():
- return [l for l in r(100)]
- def g():
- return [l for l in [1, 2, 3, 4]]
-"""
-
- # check for CO_CONTAINSGLOBALS
- assert f.func_code.co_flags & self.CO_CONTAINSGLOBALS
- assert not g.func_code.co_flags & self.CO_CONTAINSGLOBALS
-
- exec """if 1:
- b = 2
- def f(x):
- exec "a = 1";
- return a + b + x
-"""
- # check for CO_CONTAINSGLOBALS
- assert f.func_code.co_flags & self.CO_CONTAINSGLOBALS
More information about the pypy-commit
mailing list