This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aj
Recipients aj, docs@python
Date 2016-12-17.23:53:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1482018824.86.0.562219638154.issue29002@psf.upfronthosting.co.za>
In-reply-to
Content
The typing.AnyStr documentation:

https://docs.python.org/3/library/typing.html#typing.AnyStr

It gives some examples using u-strings (u'foo') but doesn't make explicit some subtleties about behaviour with Python 2. Specifically, with Python 2 all the given examples work, and even this works:

concat("foo", u"bar")

Which seems contrary to the goal of AnyStr being "used for functions that may accept any kind of string without allowing different kinds of strings to mix".

I think the documentation should call out that for Python 2, AnyStr doesn't distinguish between str & unicode, and mention that in python 2, b'str' is equivalent to 'str' (I know this is mentioned elsewhere, but it seems useful to repeat it here).
History
Date User Action Args
2016-12-17 23:53:44ajsetrecipients: + aj, docs@python
2016-12-17 23:53:44ajsetmessageid: <1482018824.86.0.562219638154.issue29002@psf.upfronthosting.co.za>
2016-12-17 23:53:44ajlinkissue29002 messages
2016-12-17 23:53:44ajcreate