I don't think this is totally correct, it's only true if `max == -1`. Otherwise you can have something like:
>>> "abc\0def\0ghi\0".split("\0", 1) ['abc', 'def\x00ghi\x00'] Alex On Tue, Mar 12, 2013 at 7:19 AM, timfel <nore...@buildbot.pypy.org> wrote: > Author: Tim Felgentreff <timfelgentr...@gmail.com> > Branch: > Changeset: r62315:156750d24e38 > Date: 2013-03-12 15:18 +0100 > http://bitbucket.org/pypy/pypy/changeset/156750d24e38/ > > Log: (cfbolz, timfel) annotate no_nul on strings in result set if > splitting at nul-byte > > diff --git a/rpython/annotator/test/test_annrpython.py > b/rpython/annotator/test/test_annrpython.py > --- a/rpython/annotator/test/test_annrpython.py > +++ b/rpython/annotator/test/test_annrpython.py > @@ -446,6 +446,17 @@ > s_item = s.listdef.listitem.s_value > assert s_item.no_nul > > + def test_str_split_nul(self): > + def f(n): > + return n.split('\0')[0] > + > + a = self.RPythonAnnotator() > + a.translator.config.translation.check_str_without_nul = True > + s = a.build_types(f, [annmodel.SomeString(no_nul=False, > can_be_None=False)]) > + assert isinstance(s, annmodel.SomeString) > + assert not s.can_be_None > + assert s.no_nul > + > def test_str_splitlines(self): > a = self.RPythonAnnotator() > def f(a_str): > diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py > --- a/rpython/annotator/unaryop.py > +++ b/rpython/annotator/unaryop.py > @@ -496,7 +496,11 @@ > > def method_split(str, patt, max=-1): > getbookkeeper().count("str_split", str, patt) > - s_item = str.basestringclass(no_nul=str.no_nul) > + if patt.is_constant() and patt.const == "\0": > + no_nul = True > + else: > + no_nul = str.no_nul > + s_item = str.basestringclass(no_nul=no_nul) > return getbookkeeper().newlist(s_item) > > def method_rsplit(str, patt, max=-1): > _______________________________________________ > pypy-commit mailing list > pypy-com...@python.org > http://mail.python.org/mailman/listinfo/pypy-commit > -- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero
_______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev