From 1cd32bb874ff81c005fe0368aa732a9e83a22d22 Mon Sep 17 00:00:00 2001 From: Damir Salantic Date: Wed, 20 Jul 2022 13:26:11 +0200 Subject: [PATCH 1/4] Issue #207 Python 3.10 --- HISTORY | 5 ++++- asterix/version.py | 2 +- src/asterix/DataItemFormatExplicit.cpp | 2 +- src/asterix/DataRecord.cpp | 2 +- src/main/version.h | 4 ++-- src/python/asterix.c | 1 + src/python/python_parser.cpp | 4 ++-- src/python/python_parser.h | 4 ++-- 8 files changed, 14 insertions(+), 10 deletions(-) diff --git a/HISTORY b/HISTORY index 4232051b..c385116d 100644 --- a/HISTORY +++ b/HISTORY @@ -255,4 +255,7 @@ Issue #182 convert timestamp to double, improves precision Issue #183 Potential Heap-based Buffer Overflow 2.8.3 (python_v0.7.3) -Issue #202 Segmentation fault in python when explicit item is wrong \ No newline at end of file +Issue #202 Segmentation fault in python when explicit item is wrong + +2.8.4 (python_v0.7.4) +Issue #207 Timestamp not created correctly \ No newline at end of file diff --git a/asterix/version.py b/asterix/version.py index 1ef13195..c9880e62 100644 --- a/asterix/version.py +++ b/asterix/version.py @@ -1 +1 @@ -__version__ = '0.7.3' +__version__ = '0.7.4' diff --git a/src/asterix/DataItemFormatExplicit.cpp b/src/asterix/DataItemFormatExplicit.cpp index 93c33248..392192e7 100644 --- a/src/asterix/DataItemFormatExplicit.cpp +++ b/src/asterix/DataItemFormatExplicit.cpp @@ -217,7 +217,7 @@ PyObject* DataItemFormatExplicit::getObject(unsigned char* pData, long nLength, if (nLength <= 1) { char errorText[256]; - snprintf(errorText, 255, "Not enough data in Explicit. There is %d byte.", nLength); + snprintf(errorText, 255, "Not enough data in Explicit. There is %ld byte.", nLength); return Py_BuildValue("s", errorText); } diff --git a/src/asterix/DataRecord.cpp b/src/asterix/DataRecord.cpp index 1c911e12..958fd8e9 100644 --- a/src/asterix/DataRecord.cpp +++ b/src/asterix/DataRecord.cpp @@ -353,7 +353,7 @@ PyObject* DataRecord::getData(int verbose) Py_DECREF(v3); PyObject* k4 = Py_BuildValue("s", "ts"); - PyObject* v4 = Py_BuildValue("l", m_nTimestamp); + PyObject* v4 = Py_BuildValue("d", m_nTimestamp); PyDict_SetItem(p, k4, v4); Py_DECREF(k4); Py_DECREF(v4); diff --git a/src/main/version.h b/src/main/version.h index 215e4c82..79e04fe0 100644 --- a/src/main/version.h +++ b/src/main/version.h @@ -26,7 +26,7 @@ #ifndef VERSION_H #define VERSION_H -#define _VERSION 2.8.3 -#define _VERSION_STR "2.8.3" +#define _VERSION 2.8.4 +#define _VERSION_STR "2.8.4" #endif diff --git a/src/python/asterix.c b/src/python/asterix.c index 6939f6c0..2d7fbeb9 100644 --- a/src/python/asterix.c +++ b/src/python/asterix.c @@ -21,6 +21,7 @@ * */ +#define PY_SSIZE_T_CLEAN #include #if PY_MAJOR_VERSION >= 3 diff --git a/src/python/python_parser.cpp b/src/python/python_parser.cpp index 4bde1ce8..9801290a 100644 --- a/src/python/python_parser.cpp +++ b/src/python/python_parser.cpp @@ -79,7 +79,7 @@ int python_init(const char *xml_config_file) { return 0; } -PyObject *python_parse(const unsigned char *pBuf, unsigned int len, int verbose) { +PyObject *python_parse(const unsigned char *pBuf, Py_ssize_t len, int verbose) { // get current timstamp in ms since epoch struct timeval tp; gettimeofday(&tp, NULL); @@ -97,7 +97,7 @@ PyObject *python_parse(const unsigned char *pBuf, unsigned int len, int verbose) } PyObject * -python_parse_with_offset(const unsigned char *pBuf, unsigned int len, unsigned int offset, unsigned int blocks_count, +python_parse_with_offset(const unsigned char *pBuf, Py_ssize_t len, unsigned int offset, unsigned int blocks_count, int verbose) /* AUTHOR: Krzysztof Rutkowski, ICM UW, krutk@icm.edu.pl */ diff --git a/src/python/python_parser.h b/src/python/python_parser.h index 8a3498d5..fad06712 100644 --- a/src/python/python_parser.h +++ b/src/python/python_parser.h @@ -33,9 +33,9 @@ extern "C" { int python_start(const char *ini_file_path); int python_init(const char *ini_file_path); PyObject *python_describe(int category, const char *item, const char *field, const char *value); -PyObject *python_parse(const unsigned char *pBuf, unsigned int len, int verbose); +PyObject *python_parse(const unsigned char *pBuf, Py_ssize_t len, int verbose); PyObject * -python_parse_with_offset(const unsigned char *pBuf, unsigned int len, unsigned int offset, unsigned int blocks_count, +python_parse_with_offset(const unsigned char *pBuf, Py_ssize_t len, unsigned int offset, unsigned int blocks_count, int verbose); void asterix_start(const char *ini_filename, const char *filename); From 3499a9151f19879dda2e0f3549f02373deb2d7aa Mon Sep 17 00:00:00 2001 From: Damir Salantic Date: Wed, 20 Jul 2022 13:44:28 +0200 Subject: [PATCH 2/4] Added PY_SSIZE_T_CLEAN --- src/python/python_parser.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python/python_parser.h b/src/python/python_parser.h index fad06712..84ccea92 100644 --- a/src/python/python_parser.h +++ b/src/python/python_parser.h @@ -24,6 +24,7 @@ #ifndef PYTHONPARSER_H_ #define PYTHONPARSER_H_ +#define PY_SSIZE_T_CLEAN #include #ifdef __cplusplus From 93da4512c36c9621636e626937d8db436582a36e Mon Sep 17 00:00:00 2001 From: Damir Salantic Date: Wed, 20 Jul 2022 13:46:10 +0200 Subject: [PATCH 3/4] Support for python 3.10 --- .travis.yml | 1 + setup.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dbb3e2e9..a1dea7a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: - '3.7' - '3.8' - '3.9' + - '3.10' before_install: - sudo apt-get -qq update - sudo apt-get install valgrind diff --git a/setup.py b/setup.py index b5b2dac1..d793c23b 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,9 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8' + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10' ] try: @@ -101,7 +103,7 @@ zip_safe=False, # eager_resources = eager_files, author="Damir Salantic", - author_email="damir.salantic@crocontrol.hr", + author_email="damir.salantic@gmail.com", download_url="https://github.com/CroatiaControlLtd/asterix", license="GPL", platforms=['any'], From 33f575e9e53aa40062cd327ddd54836e3268bd59 Mon Sep 17 00:00:00 2001 From: Damir Salantic Date: Wed, 20 Jul 2022 13:47:45 +0200 Subject: [PATCH 4/4] HISTORY updated --- HISTORY | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/HISTORY b/HISTORY index c385116d..274c31e9 100644 --- a/HISTORY +++ b/HISTORY @@ -258,4 +258,5 @@ Issue #183 Potential Heap-based Buffer Overflow Issue #202 Segmentation fault in python when explicit item is wrong 2.8.4 (python_v0.7.4) -Issue #207 Timestamp not created correctly \ No newline at end of file +Issue #207 Timestamp not created correctly +Added support for python 3.10 \ No newline at end of file