Skip to content

Commit

Permalink
Merge pull request #208 from CroatiaControlLtd/python_3_10_support
Browse files Browse the repository at this point in the history
Python 3 10 support
  • Loading branch information
dsalantic authored Jul 20, 2022
2 parents cd4dd8b + 33f575e commit ae36fb8
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,8 @@ 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
Issue #202 Segmentation fault in python when explicit item is wrong

2.8.4 (python_v0.7.4)
Issue #207 Timestamp not created correctly
Added support for python 3.10
2 changes: 1 addition & 1 deletion asterix/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.7.3'
__version__ = '0.7.4'
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion src/asterix/DataItemFormatExplicit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/asterix/DataRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/main/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/python/asterix.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*
*/

#define PY_SSIZE_T_CLEAN
#include <Python.h>

#if PY_MAJOR_VERSION >= 3
Expand Down
4 changes: 2 additions & 2 deletions src/python/python_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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, [email protected]
*/
Expand Down
5 changes: 3 additions & 2 deletions src/python/python_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#ifndef PYTHONPARSER_H_
#define PYTHONPARSER_H_

#define PY_SSIZE_T_CLEAN
#include <Python.h>

#ifdef __cplusplus
Expand All @@ -33,9 +34,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);

Expand Down

0 comments on commit ae36fb8

Please sign in to comment.