[pypy-svn] r49200 - in pypy/dist/pypy/annotation: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Nov 29 11:37:27 CET 2007
Author: cfbolz
Date: Thu Nov 29 11:37:26 2007
New Revision: 49200
Modified:
pypy/dist/pypy/annotation/binaryop.py
pypy/dist/pypy/annotation/test/test_annrpython.py
Log:
best effort detection to prevent str % unicode in RPython (which is broken
badly right now)
Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py (original)
+++ pypy/dist/pypy/annotation/binaryop.py Thu Nov 29 11:37:26 2007
@@ -438,6 +438,23 @@
def add((chr1, chr2)):
return SomeUnicodeString()
+class __extend__(pairtype(SomeString, SomeUnicodeString),
+ pairtype(SomeString, SomeUnicodeString)):
+ def mod((str, unistring)):
+ raise NotImplementedError(
+ "string formatting mixing strings and unicode not supported")
+
+
+class __extend__(pairtype(SomeString, SomeTuple)):
+ def mod((str, s_tuple)):
+ for s_item in s_tuple.items:
+ if isinstance(s_item, (SomeUnicodeCodePoint, SomeUnicodeString)):
+ raise NotImplementedError(
+ "string formatting mixing strings and unicode not supported")
+ getbookkeeper().count('strformat', str, args)
+ return SomeString()
+
+
class __extend__(pairtype(SomeString, SomeObject)):
def mod((str, args)):
Modified: pypy/dist/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/test/test_annrpython.py (original)
+++ pypy/dist/pypy/annotation/test/test_annrpython.py Thu Nov 29 11:37:26 2007
@@ -2962,6 +2962,30 @@
s = a.build_types(f, [unicode, str])
assert isinstance(s, annmodel.SomeUnicodeCodePoint)
+ def test_strformatting_unicode(self):
+ def f(x):
+ return '%s' % unichr(x)
+
+ a = self.RPythonAnnotator()
+ py.test.raises(NotImplementedError, a.build_types, f, [int])
+ def f(x):
+ return '%s' % (unichr(x) * 3)
+
+ a = self.RPythonAnnotator()
+ py.test.raises(NotImplementedError, a.build_types, f, [int])
+ def f(x):
+ return '%s%s' % (1, unichr(x))
+
+ a = self.RPythonAnnotator()
+ py.test.raises(NotImplementedError, a.build_types, f, [int])
+ def f(x):
+ return '%s%s' % (1, unichr(x) * 15)
+
+ a = self.RPythonAnnotator()
+ py.test.raises(NotImplementedError, a.build_types, f, [int])
+
+
+
def test_negative_slice(self):
def f(s, e):
return [1, 2, 3][s:e]
More information about the Pypy-commit
mailing list