blob: 49cefc1f8d25c74bd5db05edd15ca967d36e369b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
"""Python 2.x/3.x compatibility tools"""
import sys
__all__ = ['geterror', 'long_', 'xrange_', 'ord_', 'unichr_',
'unicode_', 'raw_input_']
def geterror ():
return sys.exc_info()[1]
try:
long_ = long
except NameError:
long_ = int
try:
xrange_ = xrange
except NameError:
xrange_ = range
def get_BytesIO():
try:
from cStringIO import StringIO as BytesIO
except ImportError:
from io import BytesIO
return BytesIO
def ord_(o):
try:
return ord(o)
except TypeError:
return o
try:
unichr_ = unichr
except NameError:
unichr_ = chr
try:
unicode_ = unicode
except NameError:
unicode_ = str
try:
raw_input_ = raw_input
except NameError:
raw_input_ = input
|