Commits

Armin Rigo  committed cebcd35

Hack more, by moving the check_str_without_nul at some global level.
Now Converge is happy.

  • Participants
  • Parent commits 5cc21b2

Comments (0)

Files changed (3)

File pypy/annotation/annrpython.py

         # make input arguments and set their type
         args_s = [self.typeannotation(t) for t in input_arg_types]
 
+        # XXX hack
+        annmodel.TLS.check_str_without_nul = (
+            self.translator.config.translation.check_str_without_nul)
+
         flowgraph, inputcells = self.get_call_parameters(function, args_s, policy)
         if not isinstance(flowgraph, FunctionGraph):
             assert isinstance(flowgraph, annmodel.SomeObject)

File pypy/annotation/model.py

 DEBUG = False    # set to False to disable recording of debugging information
 
 class State(object):
-    pass
+    # A global attribute :-(  Patch it with 'True' to enable checking of
+    # the no_nul attribute...
+    check_str_without_nul = False
 TLS = State()
 
 class SomeObject(object):
             return False
         d1 = self.__dict__
         d2 = other.__dict__
-        if getattr(TLS, 'ignore_no_nul', False):
-            d1 = d1.copy(); d1['no_nul'] = 0
-            d2 = d2.copy(); d2['no_nul'] = 0
+        if not TLS.check_str_without_nul:
+            d1 = d1.copy(); d1['no_nul'] = 0   # ignored
+            d2 = d2.copy(); d2['no_nul'] = 0   # ignored
         return d1 == d2
 
 class SomeString(SomeStringOrUnicode):

File pypy/rpython/extfunc.py

         assert len(args_s) == len(signature_args),\
                "Argument number mismatch"
 
-        config = self.bookkeeper.annotator.translator.config
-        if not config.translation.check_str_without_nul:
-            annmodel.TLS.ignore_no_nul = True
-        try:
-            for i, expected in enumerate(signature_args):
-                arg = annmodel.unionof(args_s[i], expected)
-                if not expected.contains(arg):
-                    name = getattr(self, 'name', None)
-                    if not name:
-                        try:
-                            name = self.instance.__name__
-                        except AttributeError:
-                            name = '?'
-                    raise Exception("In call to external function %r:\n"
-                                    "arg %d must be %s,\n"
-                                    "          got %s" % (
-                        name, i+1, expected, args_s[i]))
-        finally:
-            annmodel.TLS.ignore_no_nul = False
+        for i, expected in enumerate(signature_args):
+            arg = annmodel.unionof(args_s[i], expected)
+            if not expected.contains(arg):
+                name = getattr(self, 'name', None)
+                if not name:
+                    try:
+                        name = self.instance.__name__
+                    except AttributeError:
+                        name = '?'
+                raise Exception("In call to external function %r:\n"
+                                "arg %d must be %s,\n"
+                                "          got %s" % (
+                    name, i+1, expected, args_s[i]))
         return signature_args
 
     def compute_result_annotation(self, *args_s):
 
     def specialize_call(self, hop):
         rtyper = hop.rtyper
-        self.bookkeeper = rtyper.annotator.bookkeeper
         signature_args = self.normalize_args(*hop.args_s)
         args_r = [rtyper.getrepr(s_arg) for s_arg in signature_args]
         args_ll = [r_arg.lowleveltype for r_arg in args_r]