Message191302
| Author |
belopolsky |
| Recipients |
belopolsky, cvrebert, eric.araujo, eric.smith, ezio.melotti, lemburg, mark.dickinson, ncoghlan, skrah, vstinner |
| Date |
2013年06月17日.00:56:46 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1371430607.66.0.0911786333223.issue10581@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I took another look at the library reference and it looks like when it comes to non-ascii digits support, the reference contradicts itself. On one hand,
"""
int(x, base=10)
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in radix base. Optionally, the literal can be preceded by + or - (with no space in between) and surrounded by whitespace.
""" <http://docs.python.org/3/library/functions.html#int>
.. suggests that only "an integer literal" will be accepted by int(), but on the other hand, a note in the "Numeric Types" section says: "The numeric literals accepted include the digits 0 to 9 or any Unicode equivalent (code points with the Nd property)." <http://docs.python.org/3/library/stdtypes.html#typesnumeric>
It also appears that "surrounded by whitespace" part is not entirely correct:
>>> '\N{RS}'.isspace()
True
>>> int('123\N{RS}')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '123\x1e'
This is probably a bug in the current implementation and I will open a separate issue for that. |
|