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

Side by Side Diff: third_party/cython/src/Cython/Tempita/compat3.py

Issue 385073004: Adding cython v0.20.2 in third-party. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reference cython dev list thread. Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 import sys
2
3 __all__ = ['b', 'basestring_', 'bytes', 'next', 'is_unicode']
4
5 if sys.version < "3":
6 b = bytes = str
7 basestring_ = basestring
8 else:
9
10 def b(s):
11 if isinstance(s, str):
12 return s.encode('latin1')
13 return bytes(s)
14 basestring_ = (bytes, str)
15 bytes = bytes
16 text = str
17
18 if sys.version < "3":
19
20 def next(obj):
21 return obj.next()
22 else:
23 next = next
24
25 if sys.version < "3":
26
27 def is_unicode(obj):
28 return isinstance(obj, unicode)
29 else:
30
31 def is_unicode(obj):
32 return isinstance(obj, str)
33
34
35 def coerce_text(v):
36 if not isinstance(v, basestring_):
37 if sys.version < "3":
38 attr = '__unicode__'
39 else:
40 attr = '__str__'
41 if hasattr(v, attr):
42 return unicode(v)
43 else:
44 return bytes(v)
45 return v
OLDNEW
« no previous file with comments | « third_party/cython/src/Cython/Tempita/_tempita.py ('k') | third_party/cython/src/Cython/TestUtils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698