On Tue, Mar 25, 2008 at 11:29 AM, Nick Coghlan <[EMAIL PROTECTED]> wrote:
> The isinstance(value, str) check in Py3k is too restrictive - it needs
> to accept bytes instances as well.
>
Hmm. There's not a lot of consistency here:
>>> int(b'1')
1
>>> float(b'1')
1.0
>>> complex(b'1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: complex() argument must be a string or a number
>>> from fractions import Fraction
>>> Fraction(b'1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/dickinsm/python_source/py3k/Lib/fractions.py", line 98, in
__new__
numerator = numerator.__index__()
AttributeError: 'bytes' object has no attribute '__index__'
So int and float accepts bytes, while complex, Decimal and Fraction do
not...
Mark
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com