From f2e6b09e40f38ae6612890435be9e63211abf69b Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Tue, 12 Mar 2024 15:49:36 -0700 Subject: [PATCH] cdefing as bytes before casting --- py_gd/py_gd.pyx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/py_gd/py_gd.pyx b/py_gd/py_gd.pyx index 063082d..dafacc8 100644 --- a/py_gd/py_gd.pyx +++ b/py_gd/py_gd.pyx @@ -77,17 +77,16 @@ cdef FILE* open_file(file_path) except *: fp = NULL IF UNAME_SYSNAME == 'Windows': - bytes_flag = "wb".encode('utf-16') + cdef bytes bytes_flag = "wb".encode('utf-16') cdef char* char_flag = bytes_flag - bytes_filepath = file_path.encode('utf-16') - cdef char* char_filename = bytes_filepath + cdef bytes bytes_filepath = file_path.encode('utf-16') + # cdef char* char_filename = bytes_filepath fp = _wfopen( char_filename, char_flag) ELSE: - bytes_flag = "wb".encode('ascii') - cdef char* flag = bytes_flag - fp = fopen(file_path.encode('utf-8'), flag) + cdef bytes bytes_flag = "wb".encode('ascii') + fp = fopen(file_path.encode('utf-8'), bytes_flag) if fp is NULL: raise OSError('could not open the file: {}'.format(file_path))