[issue38003] Incorrect "fixing" of isinstance tests for basestring

Karthikeyan Singaravelan report at bugs.python.org
Sun Sep 1 18:51:06 EDT 2019


Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:

https://docs.python.org/3.0/whatsnew/3.0.html

> The builtin basestring abstract type was removed. Use str instead. The str and bytes types don’t have functionality enough in common to warrant a shared base class. The 2to3 tool (see below) replaces every occurrence of basestring with str.

For a longer explanation of this and other changes you might find below link useful. In Python 2 str is used to represent both text and bytes. Hence to check the type is str in python 2 you have to check it to be basestring and then check it to be unicode. In python 3 all strings are unicode with str and bytes being two different types. Hence there is no basestring and unicode string since they are both unified to be str itself in Python 3.

https://portingguide.readthedocs.io/en/latest/strings.html

Hope this helps.

----------
nosy: +xtreak

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38003>
_______________________________________


More information about the Python-bugs-list mailing list