|
6 | 6 | import pandas.io.common as com
|
7 | 7 | from pandas.util.testing import assert_frame_equal
|
8 | 8 |
|
9 |
| -PY3 = sys.version_info >= (3, 0) |
10 |
| - |
11 | 9 | PANDAS_VERSION = LooseVersion(pd.__version__)
|
12 | 10 |
|
13 | 11 | PANDAS_0210 = PANDAS_VERSION >= LooseVersion("0.21.0")
|
@@ -45,34 +43,20 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None, compression=None):
|
45 | 43 | )
|
46 | 44 |
|
47 | 45 |
|
48 |
| -if PY3: |
49 |
| - from urllib.error import HTTPError |
50 |
| - from functools import reduce |
51 |
| - |
52 |
| - string_types = (str,) |
53 |
| - binary_type = bytes |
54 |
| - from io import StringIO |
55 |
| - |
56 |
| - def str_to_bytes(s, encoding=None): |
57 |
| - return s.encode(encoding or "ascii") |
58 |
| - |
59 |
| - def bytes_to_str(b, encoding=None): |
60 |
| - return b.decode(encoding or "utf-8") |
| 46 | +from urllib.error import HTTPError |
| 47 | +from functools import reduce |
61 | 48 |
|
| 49 | +string_types = (str,) |
| 50 | +binary_type = bytes |
| 51 | +from io import StringIO |
62 | 52 |
|
63 |
| -else: |
64 |
| - from urllib2 import HTTPError |
65 |
| - from cStringIO import StringIO |
66 | 53 |
|
67 |
| - reduce = reduce |
68 |
| - binary_type = str |
69 |
| - string_types = (basestring,) # noqa: F821 |
| 54 | +def str_to_bytes(s, encoding=None): |
| 55 | + return s.encode(encoding or "ascii") |
70 | 56 |
|
71 |
| - def bytes_to_str(b, encoding=None): |
72 |
| - return b |
73 | 57 |
|
74 |
| - def str_to_bytes(s, encoding=None): |
75 |
| - return s |
| 58 | +def bytes_to_str(b, encoding=None): |
| 59 | + return b.decode(encoding or "utf-8") |
76 | 60 |
|
77 | 61 |
|
78 | 62 | def lmap(*args, **kwargs):
|
|
0 commit comments