Skip to content

Commit

Permalink
Drop old unused logic for Python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
benmwebb committed Jan 31, 2025
1 parent 9010b7e commit 90408b8
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions swig/RMF.buffer.i
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
/* Convert char vectors (used for binary data) to and from
Python strings (in Python 2) or bytes (in Python 3). Note
/* Convert char vectors (used for binary data) to and from Python bytes. Note
that these strings can contain embedded nulls and non-ASCII characters. */
%typemap(typecheck) const std::vector<char> & {
%#if PY_VERSION_HEX >= 0x03000000
$1 = PyBytes_Check($input) ? 1 : 0;
%#else
$1 = PyString_Check($input) ? 1 : 0;
%#endif
}

%typemap(in) const std::vector<char> & {
char *buf;
Py_ssize_t len;
if (
%#if PY_VERSION_HEX >= 0x03000000
PyBytes_AsStringAndSize
%#else
PyString_AsStringAndSize
%#endif
($input, &buf, &len) == -1) {
if (PyBytes_AsStringAndSize($input, &buf, &len) == -1) {
SWIG_fail;
} else {
$1 = new std::vector<char>(len);
Expand All @@ -30,11 +19,7 @@ PyString_AsStringAndSize
}

%typemap(out) const std::vector<char> & {
%#if PY_VERSION_HEX >= 0x03000000
$result = PyBytes_FromStringAndSize(&($1->front()), $1->size());
%#else
$result = PyString_FromStringAndSize(&($1->front()), $1->size());
%#endif
}

%extend RMF::BufferConstHandle {
Expand Down

0 comments on commit 90408b8

Please sign in to comment.