From 696c96b407c8608690b1d16168dc9bb542a7aad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henning=20P=C3=B6ttker?= <25299532+hpoettker@users.noreply.github.com> Date: Mon, 8 Jun 2026 23:12:23 +0200 Subject: [PATCH] Address compilation warnings --- pyreadstat/_readstat_parser.pyx | 22 +++++++++++----------- pyreadstat/_readstat_writer.pyx | 15 ++------------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/pyreadstat/_readstat_parser.pyx b/pyreadstat/_readstat_parser.pyx index 802fd4c..64eda3f 100644 --- a/pyreadstat/_readstat_parser.pyx +++ b/pyreadstat/_readstat_parser.pyx @@ -293,7 +293,7 @@ cdef object convert_readstat_to_python_value(readstat_value_t value, int index, cdef py_file_format file_format cdef object result - cdef char * c_str_value + cdef const char * c_str_value cdef str py_str_value cdef int8_t c_int8_value cdef int16_t c_int16_value @@ -385,15 +385,15 @@ cdef int handle_metadata(readstat_metadata_t *metadata, void *ctx) except READST cdef int var_count, obs_count, mr_len cdef data_container dc = ctx #cdef object row - cdef char * flabel_orig - cdef char * fencoding_orig + cdef const char * flabel_orig + cdef const char * fencoding_orig cdef str flabel, fencoding cdef bint metaonly - cdef char * table + cdef const char * table cdef int ctime cdef int mtime cdef int i = 0 - cdef mr_set_t * mr_sets_orig + cdef const mr_set_t * mr_sets_orig cdef dict mr_sets = {} cdef str name cdef list variable_list = [] @@ -468,9 +468,9 @@ cdef int handle_variable(int index, readstat_variable_t *variable, if any. """ - cdef char * var_name, - cdef char * var_label - cdef char * var_format + cdef const char * var_name, + cdef const char * var_label + cdef const char * var_format cdef str col_name, col_label, label_name, col_format_original, output_format cdef py_datetime_format col_format_final cdef readstat_type_t var_type @@ -742,7 +742,7 @@ cdef int handle_value_label(char *val_labels, readstat_value_t value, char *labe cdef data_container dc = ctx - cdef char * c_str_value + cdef const char * c_str_value cdef str py_str_value cdef int8_t c_int8_value cdef int16_t c_int16_value @@ -905,7 +905,7 @@ cdef void check_exit_status(readstat_error_t retcode) except *: transforms a readstat exit status to a python error if status is not READSTAT OK """ - cdef char * err_readstat + cdef const char * err_readstat cdef str err_message if retcode != READSTAT_OK: err_readstat = readstat_error_message(retcode) @@ -943,7 +943,7 @@ cdef void run_readstat_parser(char * filename, data_container data, py_file_exte metaonly = data.metaonly ctx = data - #readstat_error_t error = READSTAT_OK; + error = READSTAT_OK; parser = readstat_parser_init() metadata_handler = handle_metadata variable_handler = handle_variable diff --git a/pyreadstat/_readstat_writer.pyx b/pyreadstat/_readstat_writer.pyx index 361ef38..4ab18db 100644 --- a/pyreadstat/_readstat_writer.pyx +++ b/pyreadstat/_readstat_writer.pyx @@ -146,7 +146,8 @@ cdef double convert_datetimelike_to_number(dst_file_format file_format, pywriter converts a datime like python/pandas object to a float """ - cdef double offset_days, tstamp + cdef double offset_days + cdef double tstamp = 0 if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: offset_days = spss_offset_days @@ -574,18 +575,6 @@ cdef ssize_t write_bytes(const void *data, size_t _len, void *ctx) noexcept: else: return write(fd, data, _len) -cdef void _check_exit_status(readstat_error_t retcode) except *: - """ - transforms a readstat exit status to a python error if status is not READSTAT OK - """ - - cdef char * err_readstat - cdef str err_message - if retcode != READSTAT_OK: - err_readstat = readstat_error_message(retcode) - err_message = err_readstat - raise ReadstatError(err_message) - cdef int open_file(bytes filename_bytes): cdef int fd