@@ -123,18 +123,17 @@ def __contains__(self, key):
123123 raise TypeError (errmsg .format (type (key )))
124124 return issubset (list (newkey ), list (self ))
125125
126- @no (bytes )
126+ @no (newbytes )
127127 def __add__ (self , other ):
128128 return newstr (super (newstr , self ).__add__ (other ))
129129
130- @no (bytes )
130+ @no (newbytes )
131131 def __radd__ (self , left ):
132132 " left + self "
133- if isinstance (left , unicode ):
134- try :
135- return newstr (left ) + self
136- except :
137- raise NotImplemented
133+ try :
134+ return newstr (left ) + self
135+ except :
136+ return NotImplemented
138137
139138 def __mul__ (self , other ):
140139 return newstr (super (newstr , self ).__mul__ (other ))
@@ -149,15 +148,15 @@ def join(self, iterable):
149148 raise TypeError (errmsg .format (i ))
150149 return newstr (super (newstr , self ).join (iterable ))
151150
152- @no (bytes )
151+ @no (newbytes )
153152 def find (self , sub , * args ):
154153 return super (newstr , self ).find (sub , * args )
155154
156- @no (bytes )
155+ @no (newbytes )
157156 def rfind (self , sub , * args ):
158157 return super (newstr , self ).rfind (sub , * args )
159158
160- @no (bytes , (1 , 2 ))
159+ @no (newbytes , (1 , 2 ))
161160 def replace (self , old , new , * args ):
162161 return newstr (super (newstr , self ).replace (old , new , * args ))
163162
@@ -179,19 +178,19 @@ def encode(self, encoding='utf-8', errors='strict'):
179178 # not keyword arguments as in Python 3 str.
180179 return newbytes (super (newstr , self ).encode (encoding , errors ))
181180
182- @no (bytes , 1 )
181+ @no (newbytes , 1 )
183182 def startswith (self , prefix , * args ):
184183 if isinstance (prefix , Iterable ):
185184 for thing in prefix :
186- if not isinstance (thing , unicode ) :
185+ if type (thing ) == newbytes :
187186 raise TypeError (self .no_convert_msg .format (type (thing )))
188187 return super (newstr , self ).startswith (prefix , * args )
189188
190- @no (bytes , 1 )
189+ @no (newbytes , 1 )
191190 def endswith (self , prefix , * args ):
192191 if isinstance (prefix , Iterable ):
193192 for thing in prefix :
194- if not isinstance (thing , unicode ) :
193+ if type (thing ) == newbytes :
195194 raise TypeError (self .no_convert_msg .format (type (thing )))
196195 return super (newstr , self ).endswith (prefix , * args )
197196
@@ -203,7 +202,7 @@ def split(self, sep=None, maxsplit=-1):
203202 parts = super (newstr , self ).split (sep , maxsplit )
204203 return [newstr (part ) for part in parts ]
205204
206- @no (bytes , 1 )
205+ @no (newbytes , 1 )
207206 def rsplit (self , sep = None , maxsplit = - 1 ):
208207 # Py2 unicode.rsplit() takes maxsplit as an optional parameter,
209208 # not as a keyword argument as in Python 3 str.
@@ -212,17 +211,17 @@ def rsplit(self, sep=None, maxsplit=-1):
212211 parts = super (newstr , self ).rsplit (sep , maxsplit )
213212 return [newstr (part ) for part in parts ]
214213
215- @no (bytes , 1 )
214+ @no (newbytes , 1 )
216215 def partition (self , sep ):
217216 parts = super (newstr , self ).partition (sep )
218217 return tuple (newstr (part ) for part in parts )
219218
220- @no (bytes , 1 )
219+ @no (newbytes , 1 )
221220 def rpartition (self , sep ):
222221 parts = super (newstr , self ).rpartition (sep )
223222 return tuple (newstr (part ) for part in parts )
224223
225- @no (bytes , 1 )
224+ @no (newbytes , 1 )
226225 def index (self , sub , * args ):
227226 """
228227 Like newstr.find() but raise ValueError when the substring is not
0 commit comments