Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1451)

Unified Diff: third_party/google-endpoints/past/types/basestring.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/google-endpoints/past/types/basestring.py
diff --git a/third_party/google-endpoints/past/types/basestring.py b/third_party/google-endpoints/past/types/basestring.py
new file mode 100644
index 0000000000000000000000000000000000000000..15437bf7c8ce44063e6297b79d0edf51e28889e5
--- /dev/null
+++ b/third_party/google-endpoints/past/types/basestring.py
@@ -0,0 +1,40 @@
+"""
+An implementation of the basestring type for Python 3
+
+Example use:
+
+>>> s = b'abc'
+>>> assert isinstance(s, basestring)
+>>> from past.types import str as oldstr
+>>> s2 = oldstr(b'abc')
+>>> assert isinstance(s2, basestring)
+
+"""
+
+import sys
+
+from past.utils import with_metaclass, PY2
+
+if PY2:
+ str = unicode
+
+ver = sys.version_info[:2]
+
+
+class BaseBaseString(type):
+ def __instancecheck__(cls, instance):
+ return isinstance(instance, (bytes, str))
+
+ def __subclasshook__(cls, thing):
+ # TODO: What should go here?
+ raise NotImplemented
+
+
+class basestring(with_metaclass(BaseBaseString)):
+ """
+ A minimal backport of the Python 2 basestring type to Py3
+ """
+
+
+__all__ = ['basestring']
+
« no previous file with comments | « third_party/google-endpoints/past/types/__init__.py ('k') | third_party/google-endpoints/past/types/olddict.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698