@@ -67,8 +67,6 @@ CParserError = ParserError
6767
6868
6969cdef:
70- bint PY3 = (sys.version_info[0 ] >= 3 )
71-
7270 float64_t INF = < float64_t> np.inf
7371 float64_t NEGINF = - INF
7472
@@ -633,12 +631,7 @@ cdef class TextReader:
633631 source = gzip.GzipFile(fileobj = source)
634632 elif self .compression == ' bz2' :
635633 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' )
642635 elif self .compression == ' zip' :
643636 import zipfile
644637 zip_file = zipfile.ZipFile(source)
@@ -1396,19 +1389,12 @@ def _ensure_encoded(list lst):
13961389 if isinstance (x, unicode ):
13971390 x = PyUnicode_AsUTF8String(x)
13981391 elif not isinstance (x, bytes):
1399- x = asbytes(x )
1392+ x = str (x).encode( ' utf-8 ' )
14001393
14011394 result.append(x)
14021395 return result
14031396
14041397
1405- cdef asbytes(object o):
1406- if PY3:
1407- return str (o).encode(' utf-8' )
1408- else :
1409- return str (o)
1410-
1411-
14121398# common NA values
14131399# no longer excluding inf representations
14141400# '1.#INF','-1.#INF', '1.#INF000000',
@@ -1441,10 +1427,7 @@ cdef enum StringPath:
14411427cdef inline StringPath _string_path(char * encoding):
14421428 if encoding != NULL and encoding != b" utf-8" :
14431429 return ENCODED
1444- elif PY3 or encoding != NULL :
1445- return UTF8
1446- else :
1447- return CSTRING
1430+ return UTF8
14481431
14491432
14501433# ----------------------------------------------------------------------
@@ -2155,10 +2138,7 @@ cdef raise_parser_error(object base, parser_t *parser):
21552138
21562139 message = ' {base}. C error: ' .format(base = base)
21572140 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' )
21622142 else :
21632143 message += ' no error message set'
21642144
@@ -2257,12 +2237,7 @@ cdef _apply_converter(object f, parser_t *parser, int64_t col,
22572237
22582238 coliter_setup(& it, parser, col, line_start)
22592239
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' :
22662241 for i in range (lines):
22672242 COLITER_NEXT(it, word)
22682243 val = PyUnicode_FromString(word)
0 commit comments