[pypy-svn] pypy default: Attempt to fix the issue shown by

arigo commits-noreply at bitbucket.org
Mon Feb 7 23:38:25 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r41693:3923b795b4f8
Date: 2011-02-07 23:37 +0100
http://bitbucket.org/pypy/pypy/changeset/3923b795b4f8/

Log:	Attempt to fix the issue shown by
	test_appinterp:test_geninterp_can_unfreeze.

diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py
--- a/pypy/interpreter/mixedmodule.py
+++ b/pypy/interpreter/mixedmodule.py
@@ -108,6 +108,7 @@
         self.getdict()
         self.w_initialdict = None
         self.startup_called = False
+        self._frozen = True
         # hint for the annotator: Modules can hold state, so they are
         # not constant
         return False

diff --git a/pypy/interpreter/module.py b/pypy/interpreter/module.py
--- a/pypy/interpreter/module.py
+++ b/pypy/interpreter/module.py
@@ -4,10 +4,13 @@
 
 from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.error import OperationError
+from pypy.rlib.objectmodel import we_are_translated
 
 class Module(Wrappable):
     """A module."""
 
+    _frozen = False
+
     def __init__(self, space, w_name, w_dict=None):
         self.space = space
         if w_dict is None: 
@@ -26,6 +29,12 @@
         """This is called each time the module is imported or reloaded
         """
         if not self.startup_called:
+            if not we_are_translated():
+                # this special case is to handle the case, during annotation,
+                # of module A that gets frozen, then module B (e.g. during
+                # a getdict()) runs some code that imports A
+                if self._frozen:
+                    return
             self.startup_called = True
             self.startup(space)
 


More information about the Pypy-commit mailing list