[pypy-commit] pypy string-NUL: Rename to SomeString.no_nul

amauryfa noreply at buildbot.pypy.org
Sat Jan 28 21:26:26 CET 2012


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: string-NUL
Changeset: r51939:ad0aa0ec7a90
Date: 2012-01-28 21:26 +0100
http://bitbucket.org/pypy/pypy/changeset/ad0aa0ec7a90/

Log:	Rename to SomeString.no_nul

diff --git a/pypy/annotation/binaryop.py b/pypy/annotation/binaryop.py
--- a/pypy/annotation/binaryop.py
+++ b/pypy/annotation/binaryop.py
@@ -435,8 +435,8 @@
 
     def union((str1, str2)):
         result = SomeString(can_be_None=str1.can_be_None or str2.can_be_None)
-        if str1.no_NUL and str2.no_NUL:
-            result.no_NUL = True
+        if str1.no_nul and str2.no_nul:
+            result.no_nul = True
         return result
 
     def add((str1, str2)):
@@ -444,8 +444,8 @@
         result = SomeString()
         if str1.is_immutable_constant() and str2.is_immutable_constant():
             result.const = str1.const + str2.const
-        if str1.no_NUL and str2.no_NUL:
-            result.no_NUL = True
+        if str1.no_nul and str2.no_nul:
+            result.no_nul = True
         return result
 
 class __extend__(pairtype(SomeChar, SomeChar)):
@@ -481,17 +481,17 @@
                     "string formatting mixing strings and unicode not supported")
         getbookkeeper().count('strformat', str, s_tuple)
         result = SomeString()
-        no_NUL = str.no_NUL
+        no_nul = str.no_nul
         for s_item in s_tuple.items:
             if isinstance(s_item, SomeFloat):
                 pass
-            elif isinstance(s_item, SomeString) and s_item.no_NUL:
+            elif isinstance(s_item, SomeString) and s_item.no_nul:
                 pass
             else:
-                no_NUL = False
+                no_nul = False
                 break
-        if no_NUL:
-            result.no_NUL = True
+        if no_nul:
+            result.no_nul = True
         return result
 
 
@@ -859,7 +859,7 @@
 
 _make_none_union('SomeInstance',   'classdef=obj.classdef, can_be_None=True')
 _make_none_union('SomeString',      'can_be_None=True',
-                 copy_attributes=('no_NUL',))
+                 copy_attributes=('no_nul',))
 _make_none_union('SomeUnicodeString', 'can_be_None=True')
 _make_none_union('SomeList',         'obj.listdef')
 _make_none_union('SomeDict',          'obj.dictdef')
diff --git a/pypy/annotation/bookkeeper.py b/pypy/annotation/bookkeeper.py
--- a/pypy/annotation/bookkeeper.py
+++ b/pypy/annotation/bookkeeper.py
@@ -345,11 +345,11 @@
             if len(x) == 1:
                 result = SomeChar()
                 if not '\x00' in x:
-                    result.no_NUL = True
+                    result.no_nul = True
             else:
                 result = SomeString()
                 if not '\x00' in x:
-                    result.no_NUL = True
+                    result.no_nul = True
         elif tp is unicode:
             if len(x) == 1:
                 result = SomeUnicodeCodePoint()
diff --git a/pypy/annotation/model.py b/pypy/annotation/model.py
--- a/pypy/annotation/model.py
+++ b/pypy/annotation/model.py
@@ -230,7 +230,7 @@
     knowntype = str
     immutable = True
     can_be_None=False
-    no_NUL = False
+    no_nul = False  # No NUL character in the string.
 
     def __init__(self, can_be_None=False):
         if can_be_None:
@@ -241,15 +241,15 @@
 
     def nonnoneify(self):
         result = SomeString(can_be_None=False)
-        if self.no_NUL:
-            result.no_NUL = True
+        if self.no_nul:
+            result.no_nul = True
         return result
 
 class SomeUnicodeString(SomeObject):
     "Stands for an object which is known to be an unicode string"
     knowntype = unicode
     immutable = True
-    no_NUL = False
+    no_nul = False
     def __init__(self, can_be_None=False):
         self.can_be_None = can_be_None
 
@@ -511,7 +511,7 @@
 s_Bool = SomeBool()
 s_ImpossibleValue = SomeImpossibleValue()
 s_Str0 = SomeString()
-s_Str0.no_NUL = True
+s_Str0.no_nul = True
 
 # ____________________________________________________________
 # weakrefs
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
@@ -456,7 +456,7 @@
             return ''.join(g(n))
         s = a.build_types(f, [int])
         assert s.knowntype == str
-        assert s.no_NUL
+        assert s.no_nul
 
     def test_str_split(self):
         a = self.RPythonAnnotator()
@@ -469,7 +469,7 @@
         s = a.build_types(f, [int])
         assert isinstance(s, annmodel.SomeList)
         s_item = s.listdef.listitem.s_value
-        assert s_item.no_NUL
+        assert s_item.no_nul
 
     def test_str_splitlines(self):
         a = self.RPythonAnnotator()
@@ -2041,7 +2041,7 @@
         a = self.RPythonAnnotator()
         s = a.build_types(f, [int])
         assert s.can_be_None
-        assert s.no_NUL
+        assert s.no_nul
 
     def test_str_or_None(self):
         def f(a):
@@ -2061,7 +2061,7 @@
         a = self.RPythonAnnotator()
         s = a.build_types(f, [int])
         assert s.can_be_None
-        assert s.no_NUL
+        assert s.no_nul
 
     def test_emulated_pbc_call_simple(self):
         def f(a,b):
@@ -2127,7 +2127,7 @@
         a = self.RPythonAnnotator()
         s = a.build_types(f, [])
         assert isinstance(s, annmodel.SomeString)
-        assert s.no_NUL
+        assert s.no_nul
 
     def test_non_none_and_none_with_isinstance(self):
         class A(object):
diff --git a/pypy/annotation/unaryop.py b/pypy/annotation/unaryop.py
--- a/pypy/annotation/unaryop.py
+++ b/pypy/annotation/unaryop.py
@@ -492,8 +492,8 @@
                 return immutablevalue(u"")
             return immutablevalue("")
         result = str.basestringclass()
-        if str.no_NUL and s_item.no_NUL:
-            result.no_NUL = True
+        if str.no_nul and s_item.no_nul:
+            result.no_nul = True
         return result
 
     def iter(str):
@@ -506,16 +506,16 @@
     def method_split(str, patt, max=-1):
         getbookkeeper().count("str_split", str, patt)
         s_item = str.basestringclass()
-        if str.no_NUL:
-            s_item.no_NUL = True
+        if str.no_nul:
+            s_item.no_nul = True
         result = getbookkeeper().newlist(s_item)
         return result
 
     def method_rsplit(str, patt, max=-1):
         getbookkeeper().count("str_rsplit", str, patt)
         result = getbookkeeper().newlist(str.basestringclass())
-        if str.no_NUL:
-            result.no_NUL = True
+        if str.no_nul:
+            result.no_nul = True
         return result
 
     def method_replace(str, s1, s2):
@@ -524,8 +524,8 @@
     def getslice(str, s_start, s_stop):
         check_negative_slice(s_start, s_stop)
         result = str.basestringclass()
-        if str.no_NUL:
-            result.no_NUL = True
+        if str.no_nul:
+            result.no_nul = True
         return result
 
 class __extend__(SomeUnicodeString):
diff --git a/pypy/rlib/rstring.py b/pypy/rlib/rstring.py
--- a/pypy/rlib/rstring.py
+++ b/pypy/rlib/rstring.py
@@ -206,7 +206,7 @@
         return SomeUnicodeBuilder(can_be_None=True)
 
 #___________________________________________________________________
-# Support functions for SomeString.no_NUL
+# Support functions for SomeString.no_nul
 
 def assert_str0(fname):
     assert '\x00' not in fname, "NUL byte in string"
@@ -217,11 +217,11 @@
 
     def compute_result_annotation(self, s_obj):
         assert isinstance(s_obj, (SomeString, SomeUnicodeString))
-        if s_obj.no_NUL:
+        if s_obj.no_nul:
             return s_obj
         new_s_obj = SomeObject.__new__(s_obj.__class__)
         new_s_obj.__dict__ = s_obj.__dict__.copy()
-        new_s_obj.no_NUL = True
+        new_s_obj.no_nul = True
         return new_s_obj
 
     def specialize_call(self, hop):
@@ -239,8 +239,8 @@
     def compute_result_annotation(self, s_obj):
         if not isinstance(s_obj, SomeString):
             return s_obj
-        if not s_obj.no_NUL:
-            raise ValueError("Value is not no_NUL")
+        if not s_obj.no_nul:
+            raise ValueError("Value is not no_nul")
 
     def specialize_call(self, hop):
         pass
diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -32,10 +32,10 @@
 from pypy.rlib.objectmodel import specialize
 
 str0 = SomeString()
-str0.no_NUL = True
+str0.no_nul = True
 
 unicode0 = SomeUnicodeString()
-unicode0.no_NUL = True
+unicode0.no_nul = True
 
 def monkeypatch_rposix(posixfunc, unicodefunc, signature):
     func_name = posixfunc.__name__


More information about the pypy-commit mailing list