@@ -302,24 +302,28 @@ def __ne__(self, other):
302
302
unorderable_err = 'unorderable types: str() and {0}'
303
303
304
304
def __lt__ (self , other ):
305
- if not istext (other ):
306
- raise TypeError (self .unorderable_err .format (type (other )))
307
- return super (newstr , self ).__lt__ (other )
305
+ if (isinstance (other , unicode ) or
306
+ isinstance (other , bytes ) and not isnewbytes (other )):
307
+ return super (newstr , self ).__lt__ (other )
308
+ raise TypeError (self .unorderable_err .format (type (other )))
308
309
309
310
def __le__ (self , other ):
310
- if not istext (other ):
311
- raise TypeError (self .unorderable_err .format (type (other )))
312
- return super (newstr , self ).__le__ (other )
311
+ if (isinstance (other , unicode ) or
312
+ isinstance (other , bytes ) and not isnewbytes (other )):
313
+ return super (newstr , self ).__le__ (other )
314
+ raise TypeError (self .unorderable_err .format (type (other )))
313
315
314
316
def __gt__ (self , other ):
315
- if not istext (other ):
316
- raise TypeError (self .unorderable_err .format (type (other )))
317
- return super (newstr , self ).__gt__ (other )
317
+ if (isinstance (other , unicode ) or
318
+ isinstance (other , bytes ) and not isnewbytes (other )):
319
+ return super (newstr , self ).__gt__ (other )
320
+ raise TypeError (self .unorderable_err .format (type (other )))
318
321
319
322
def __ge__ (self , other ):
320
- if not istext (other ):
321
- raise TypeError (self .unorderable_err .format (type (other )))
322
- return super (newstr , self ).__ge__ (other )
323
+ if (isinstance (other , unicode ) or
324
+ isinstance (other , bytes ) and not isnewbytes (other )):
325
+ return super (newstr , self ).__ge__ (other )
326
+ raise TypeError (self .unorderable_err .format (type (other )))
323
327
324
328
def __getattribute__ (self , name ):
325
329
"""
0 commit comments