[pypy-svn] r7467 - pypy/trunk/src/pypy/annotation

arigo at codespeak.net arigo at codespeak.net
Fri Nov 19 19:11:28 CET 2004


Author: arigo
Date: Fri Nov 19 19:11:26 2004
New Revision: 7467

Modified:
   pypy/trunk/src/pypy/annotation/factory.py
   pypy/trunk/src/pypy/annotation/model.py
Log:
Bug: a missing factory.  See the comment.


Modified: pypy/trunk/src/pypy/annotation/factory.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/factory.py	(original)
+++ pypy/trunk/src/pypy/annotation/factory.py	Fri Nov 19 19:11:26 2004
@@ -55,6 +55,9 @@
         del getthreadlocals().bookkeeper
         del self.position_key
 
+    def is_in_an_operation(self):
+        return hasattr(self, 'position_key')
+
     def getfactory(self, factorycls):
         """Get the Factory associated with the current position,
         or build it if it doesn't exist yet."""

Modified: pypy/trunk/src/pypy/annotation/model.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/model.py	(original)
+++ pypy/trunk/src/pypy/annotation/model.py	Fri Nov 19 19:11:26 2004
@@ -270,7 +270,16 @@
     # can't do dict, tuple
     elif isinstance(t, (type, ClassType)) and \
              t.__module__ != '__builtin__' and bookkeeper is not None:
-        return SomeInstance(bookkeeper.getclassdef(t))
+        classdef = bookkeeper.getclassdef(t)
+        if bookkeeper.is_in_an_operation():
+            # woha! instantiating a "mutable" SomeXxx like SomeInstance
+            # is always dangerous, because we need to record this fact
+            # in a factory, to allow reflowing from the current operation
+            # if/when the classdef later changes.
+            from pypy.annotation.factory import CallableFactory
+            factory = bookkeeper.getfactory(CallableFactory)
+            classdef.instancefactories[factory] = True
+        return SomeInstance(classdef)
     else:
         o = SomeObject()
         o.knowntype = t



More information about the Pypy-commit mailing list