Author: Armin Rigo <[email protected]>
Branch:
Changeset: r52112:cebcd354652f
Date: 2012-02-05 19:26 +0100
http://bitbucket.org/pypy/pypy/changeset/cebcd354652f/
Log: Hack more, by moving the check_str_without_nul at some global level.
Now Converge is happy.
diff --git a/pypy/annotation/annrpython.py b/pypy/annotation/annrpython.py
--- a/pypy/annotation/annrpython.py
+++ b/pypy/annotation/annrpython.py
@@ -93,6 +93,10 @@
# 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)
diff --git a/pypy/annotation/model.py b/pypy/annotation/model.py
--- a/pypy/annotation/model.py
+++ b/pypy/annotation/model.py
@@ -39,7 +39,9 @@
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):
@@ -244,9 +246,9 @@
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):
diff --git a/pypy/rpython/extfunc.py b/pypy/rpython/extfunc.py
--- a/pypy/rpython/extfunc.py
+++ b/pypy/rpython/extfunc.py
@@ -152,25 +152,19 @@
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):
@@ -179,7 +173,6 @@
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]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit