Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/past/types/basestring.py: 100%
12 statements
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:53 +0000
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:53 +0000
1"""
2An implementation of the basestring type for Python 3
4Example use:
6>>> s = b'abc'
7>>> assert isinstance(s, basestring)
8>>> from past.types import str as oldstr
9>>> s2 = oldstr(b'abc')
10>>> assert isinstance(s2, basestring)
12"""
14import sys
16from past.utils import with_metaclass, PY2
18if PY2:
19 str = unicode
21ver = sys.version_info[:2]
24class BaseBaseString(type):
25 def __instancecheck__(cls, instance):
26 return isinstance(instance, (bytes, str))
28 def __subclasscheck__(cls, subclass):
29 return super(BaseBaseString, cls).__subclasscheck__(subclass) or issubclass(subclass, (bytes, str))
32class basestring(with_metaclass(BaseBaseString)):
33 """
34 A minimal backport of the Python 2 basestring type to Py3
35 """
38__all__ = ['basestring']