Author: Amaury Forgeot d'Arc <[email protected]>
Branch:
Changeset: r52091:e0a0dfed7e85
Date: 2012-02-04 15:52 +0100
http://bitbucket.org/pypy/pypy/changeset/e0a0dfed7e85/
Log: str.strip() preserves the no_nul-ness of a string.
diff --git a/pypy/annotation/test/test_annrpython.py
b/pypy/annotation/test/test_annrpython.py
--- a/pypy/annotation/test/test_annrpython.py
+++ b/pypy/annotation/test/test_annrpython.py
@@ -479,6 +479,18 @@
assert isinstance(s, annmodel.SomeList)
assert s.listdef.listitem.resized
+ def test_str_strip(self):
+ a = self.RPythonAnnotator()
+ def f(n, a_str):
+ if n == 0:
+ return a_str.strip(' ')
+ elif n == 1:
+ return a_str.rstrip(' ')
+ else:
+ return a_str.lstrip(' ')
+ s = a.build_types(f, [int, annmodel.SomeString(no_nul=True)])
+ assert s.no_nul
+
def test_str_mul(self):
a = self.RPythonAnnotator()
def f(a_str):
diff --git a/pypy/annotation/unaryop.py b/pypy/annotation/unaryop.py
--- a/pypy/annotation/unaryop.py
+++ b/pypy/annotation/unaryop.py
@@ -480,13 +480,13 @@
return SomeInteger(nonneg=True)
def method_strip(str, chr):
- return str.basestringclass()
+ return str.basestringclass(no_nul=str.no_nul)
def method_lstrip(str, chr):
- return str.basestringclass()
+ return str.basestringclass(no_nul=str.no_nul)
def method_rstrip(str, chr):
- return str.basestringclass()
+ return str.basestringclass(no_nul=str.no_nul)
def method_join(str, s_list):
if s_None.contains(s_list):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit