@@ -123,11 +123,11 @@ def __contains__(self, key):
123
123
raise TypeError (errmsg .format (type (key )))
124
124
return issubset (list (newkey ), list (self ))
125
125
126
- @no (bytes )
126
+ @no (newbytes )
127
127
def __add__ (self , other ):
128
128
return newstr (super (newstr , self ).__add__ (other ))
129
129
130
- @no (bytes )
130
+ @no (newbytes )
131
131
def __radd__ (self , left ):
132
132
" left + self "
133
133
try :
@@ -149,21 +149,22 @@ def join(self, iterable):
149
149
raise TypeError (errmsg .format (i ))
150
150
return newstr (super (newstr , self ).join (iterable ))
151
151
152
- @no (bytes )
152
+ @no (newbytes )
153
153
def find (self , sub , * args ):
154
154
return super (newstr , self ).find (sub , * args )
155
155
156
- @no (bytes )
156
+ @no (newbytes )
157
157
def rfind (self , sub , * args ):
158
158
return super (newstr , self ).rfind (sub , * args )
159
159
160
- @no (bytes , (1 , 2 ))
160
+ @no (newbytes , (1 , 2 ))
161
161
def replace (self , old , new , * args ):
162
162
return newstr (super (newstr , self ).replace (old , new , * args ))
163
163
164
164
def decode (self , * args ):
165
165
raise AttributeError ("decode method has been disabled in newstr" )
166
166
167
+ @no (newbytes , (1 , 2 ))
167
168
def encode (self , encoding = 'utf-8' , errors = 'strict' ):
168
169
"""
169
170
Returns bytes
@@ -179,22 +180,23 @@ def encode(self, encoding='utf-8', errors='strict'):
179
180
# not keyword arguments as in Python 3 str.
180
181
return newbytes (super (newstr , self ).encode (encoding , errors ))
181
182
182
- @no (bytes , 1 )
183
+ @no (newbytes , 1 )
183
184
def startswith (self , prefix , * args ):
184
185
if isinstance (prefix , Iterable ):
185
186
for thing in prefix :
186
187
if not isinstance (thing , unicode ):
187
188
raise TypeError (self .no_convert_msg .format (type (thing )))
188
189
return super (newstr , self ).startswith (prefix , * args )
189
190
190
- @no (bytes , 1 )
191
+ @no (newbytes , 1 )
191
192
def endswith (self , prefix , * args ):
192
193
if isinstance (prefix , Iterable ):
193
194
for thing in prefix :
194
195
if not isinstance (thing , unicode ):
195
196
raise TypeError (self .no_convert_msg .format (type (thing )))
196
197
return super (newstr , self ).endswith (prefix , * args )
197
198
199
+ @no (newbytes , 1 )
198
200
def split (self , sep = None , maxsplit = - 1 ):
199
201
# Py2 unicode.split() takes maxsplit as an optional parameter,
200
202
# not as a keyword argument as in Python 3 str.
@@ -203,7 +205,7 @@ def split(self, sep=None, maxsplit=-1):
203
205
parts = super (newstr , self ).split (sep , maxsplit )
204
206
return [newstr (part ) for part in parts ]
205
207
206
- @no (bytes , 1 )
208
+ @no (newbytes , 1 )
207
209
def rsplit (self , sep = None , maxsplit = - 1 ):
208
210
# Py2 unicode.rsplit() takes maxsplit as an optional parameter,
209
211
# not as a keyword argument as in Python 3 str.
@@ -212,17 +214,17 @@ def rsplit(self, sep=None, maxsplit=-1):
212
214
parts = super (newstr , self ).rsplit (sep , maxsplit )
213
215
return [newstr (part ) for part in parts ]
214
216
215
- @no (bytes , 1 )
217
+ @no (newbytes , 1 )
216
218
def partition (self , sep ):
217
219
parts = super (newstr , self ).partition (sep )
218
220
return tuple (newstr (part ) for part in parts )
219
221
220
- @no (bytes , 1 )
222
+ @no (newbytes , 1 )
221
223
def rpartition (self , sep ):
222
224
parts = super (newstr , self ).rpartition (sep )
223
225
return tuple (newstr (part ) for part in parts )
224
226
225
- @no (bytes , 1 )
227
+ @no (newbytes , 1 )
226
228
def index (self , sub , * args ):
227
229
"""
228
230
Like newstr.find() but raise ValueError when the substring is not
@@ -248,22 +250,22 @@ def __ne__(self, other):
248
250
unorderable_err = 'unorderable types: str() and {0}'
249
251
250
252
def __lt__ (self , other ):
251
- if not istext (other ):
253
+ if not isinstance (other , unicode ):
252
254
raise TypeError (self .unorderable_err .format (type (other )))
253
255
return super (newbytes , self ).__lt__ (other )
254
256
255
257
def __le__ (self , other ):
256
- if not istext (other ):
258
+ if not isinstance (other , unicode ):
257
259
raise TypeError (self .unorderable_err .format (type (other )))
258
260
return super (newbytes , self ).__le__ (other )
259
261
260
262
def __gt__ (self , other ):
261
- if not istext (other ):
263
+ if not isinstance (other , unicode ):
262
264
raise TypeError (self .unorderable_err .format (type (other )))
263
265
return super (newbytes , self ).__gt__ (other )
264
266
265
267
def __ge__ (self , other ):
266
- if not istext (other ):
268
+ if not isinstance (other , unicode ):
267
269
raise TypeError (self .unorderable_err .format (type (other )))
268
270
return super (newbytes , self ).__ge__ (other )
269
271
0 commit comments