Author inada.naoki
Recipients inada.naoki
Date 2018-01-26.11:09:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1516964948.19.0.467229070634.issue32677@psf.upfronthosting.co.za>
In-reply-to
Content
int() and str.is*** functions accepts other than ASCII.
But we want to accept only ASCII in some cases.  (e.g. ipaddress module)

We can use try-except to check ASCII, but it's inefficient.

try:
    s.encode('ascii')
except UnicodeEncodeError:
    ascii = False
else:
    ascii = True

CPython can check string is ASCII efficiently.

(Voting on python-ideas ML now)
History
Date User Action Args
2018-01-26 11:09:08inada.naokisetrecipients: + inada.naoki
2018-01-26 11:09:08inada.naokisetmessageid: <1516964948.19.0.467229070634.issue32677@psf.upfronthosting.co.za>
2018-01-26 11:09:08inada.naokilinkissue32677 messages
2018-01-26 11:09:08inada.naokicreate