* Fix python3 error

This commit is contained in:
Matthew Honnibal 2015-07-23 14:30:29 +02:00
parent b81ffe9032
commit 99387f9572
1 changed files with 1 additions and 1 deletions

View File

@ -4,7 +4,7 @@ from libc.stdio cimport fopen, fclose, fread, fwrite, FILE
cdef class CFile: cdef class CFile:
def __init__(self, loc, mode): def __init__(self, loc, mode):
if isinstance(mode, unicode): if isinstance(mode, unicode):
mode_str = mode.decode('ascii') mode_str = mode.encode('ascii')
cdef bytes bytes_loc = loc.encode('utf8') if type(loc) == unicode else loc cdef bytes bytes_loc = loc.encode('utf8') if type(loc) == unicode else loc
self.fp = fopen(<char*>bytes_loc, mode) self.fp = fopen(<char*>bytes_loc, mode)
if self.fp == NULL: if self.fp == NULL: