Author: Philip Jenvey <pjen...@underboss.org> Branch: py3k Changeset: r62039:ec6e34cac076 Date: 2013-03-04 18:31 -0800 http://bitbucket.org/pypy/pypy/changeset/ec6e34cac076/
Log: match cpython: top level defs may have CO_NOFREE diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py --- a/pypy/interpreter/astcompiler/codegen.py +++ b/pypy/interpreter/astcompiler/codegen.py @@ -1198,7 +1198,10 @@ tree.walkabout(self) def _get_code_flags(self): - return 0 + flags = 0 + if not self.cell_vars and not self.free_vars: + flags |= consts.CO_NOFREE + return flags class AbstractFunctionCodeGenerator(PythonCodeGenerator): 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 @@ -10,6 +10,7 @@ cls.w_file = cls.space.wrap(filename) cls.w_CO_CONTAINSGLOBALS = cls.space.wrap(consts.CO_CONTAINSGLOBALS) + cls.w_CO_NOFREE = cls.space.wrap(consts.CO_NOFREE) def test_attributes(self): def f(): pass @@ -169,6 +170,8 @@ assert res.endswith('>') def test_code_extra(self): + assert compile("x = x + 1", 'baz', 'exec').co_flags & self.CO_NOFREE + d = {} exec("""if 1: def f(): @@ -178,7 +181,7 @@ """, d) # check for new flag, CO_NOFREE - assert d['f'].__code__.co_flags & 0x40 + assert d['f'].__code__.co_flags & self.CO_NOFREE exec("""if 1: def f(x): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit