equal
deleted
inserted
replaced
259 def __new__(cls: Type[_Tbytestr], s: object = b'') -> _Tbytestr: |
259 def __new__(cls: Type[_Tbytestr], s: object = b'') -> _Tbytestr: |
260 if isinstance(s, bytestr): |
260 if isinstance(s, bytestr): |
261 return s |
261 return s |
262 if not isinstance(s, (bytes, bytearray)) and ( |
262 if not isinstance(s, (bytes, bytearray)) and ( |
263 isinstance(s, type) |
263 isinstance(s, type) |
264 or not builtins.hasattr(s, u'__bytes__') # hasattr-py3-only |
264 or not builtins.hasattr(s, '__bytes__') # hasattr-py3-only |
265 ): |
265 ): |
266 s = str(s).encode('ascii') |
266 s = str(s).encode('ascii') |
267 return bytes.__new__(cls, s) |
267 return bytes.__new__(cls, s) |
268 |
268 |
269 # The base class uses `int` return in py3, but the point of this class is to |
269 # The base class uses `int` return in py3, but the point of this class is to |