Skip to content

Commit

Permalink
cdefing as bytes before casting
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBarker-NOAA committed Mar 12, 2024
1 parent 0ef1b4a commit f2e6b09
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions py_gd/py_gd.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<wchar_t*> char_filename, <wchar_t*> 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))
Expand Down

0 comments on commit f2e6b09

Please sign in to comment.