@@ -67,8 +67,6 @@ CParserError = ParserError
67
67
68
68
69
69
cdef:
70
- bint PY3 = (sys.version_info[0 ] >= 3 )
71
-
72
70
float64_t INF = < float64_t> np.inf
73
71
float64_t NEGINF = - INF
74
72
@@ -633,12 +631,7 @@ cdef class TextReader:
633
631
source = gzip.GzipFile(fileobj = source)
634
632
elif self .compression == ' bz2' :
635
633
import bz2
636
- if isinstance (source, basestring ) or PY3:
637
- source = bz2.BZ2File(source, ' rb' )
638
- else :
639
- content = source.read()
640
- source.close()
641
- source = compat.StringIO(bz2.decompress(content))
634
+ source = bz2.BZ2File(source, ' rb' )
642
635
elif self .compression == ' zip' :
643
636
import zipfile
644
637
zip_file = zipfile.ZipFile(source)
@@ -1396,19 +1389,12 @@ def _ensure_encoded(list lst):
1396
1389
if isinstance (x, unicode ):
1397
1390
x = PyUnicode_AsUTF8String(x)
1398
1391
elif not isinstance (x, bytes):
1399
- x = asbytes(x )
1392
+ x = str (x).encode( ' utf-8 ' )
1400
1393
1401
1394
result.append(x)
1402
1395
return result
1403
1396
1404
1397
1405
- cdef asbytes(object o):
1406
- if PY3:
1407
- return str (o).encode(' utf-8' )
1408
- else :
1409
- return str (o)
1410
-
1411
-
1412
1398
# common NA values
1413
1399
# no longer excluding inf representations
1414
1400
# '1.#INF','-1.#INF', '1.#INF000000',
@@ -1441,10 +1427,7 @@ cdef enum StringPath:
1441
1427
cdef inline StringPath _string_path(char * encoding):
1442
1428
if encoding != NULL and encoding != b" utf-8" :
1443
1429
return ENCODED
1444
- elif PY3 or encoding != NULL :
1445
- return UTF8
1446
- else :
1447
- return CSTRING
1430
+ return UTF8
1448
1431
1449
1432
1450
1433
# ----------------------------------------------------------------------
@@ -2155,10 +2138,7 @@ cdef raise_parser_error(object base, parser_t *parser):
2155
2138
2156
2139
message = ' {base}. C error: ' .format(base = base)
2157
2140
if parser.error_msg != NULL :
2158
- if PY3:
2159
- message += parser.error_msg.decode(' utf-8' )
2160
- else :
2161
- message += parser.error_msg
2141
+ message += parser.error_msg.decode(' utf-8' )
2162
2142
else :
2163
2143
message += ' no error message set'
2164
2144
@@ -2257,12 +2237,7 @@ cdef _apply_converter(object f, parser_t *parser, int64_t col,
2257
2237
2258
2238
coliter_setup(& it, parser, col, line_start)
2259
2239
2260
- if not PY3 and c_encoding == NULL :
2261
- for i in range (lines):
2262
- COLITER_NEXT(it, word)
2263
- val = PyBytes_FromString(word)
2264
- result[i] = f(val)
2265
- elif ((PY3 and c_encoding == NULL ) or c_encoding == b' utf-8' ):
2240
+ if c_encoding == NULL or c_encoding == b' utf-8' :
2266
2241
for i in range (lines):
2267
2242
COLITER_NEXT(it, word)
2268
2243
val = PyUnicode_FromString(word)
0 commit comments