* Fix CFile for Python2

This commit is contained in:
Matthew Honnibal 2015-07-25 22:55:53 +02:00
parent 8e800adfbc
commit 3fe14b8ed6

View File

@ -5,6 +5,8 @@ cdef class CFile:
def __init__(self, loc, mode):
if isinstance(mode, unicode):
mode_str = mode.encode('ascii')
else:
mode_str = mode
cdef bytes bytes_loc = loc.encode('utf8') if type(loc) == unicode else loc
self.fp = fopen(<char*>bytes_loc, mode_str)
if self.fp == NULL: