Dropped conditional compiling dealing with unsupported versions

Also dropped shameful use of PY_MINOR_VERSION.
This commit is contained in:
Daniele Varrazzo 2019-03-16 17:20:31 +00:00
parent dfb301b42b
commit 8448b3b840
2 changed files with 1 additions and 12 deletions

View File

@ -46,7 +46,6 @@ binary_escape(unsigned char *from, size_t from_length,
} }
#define HAS_BUFFER (PY_MAJOR_VERSION < 3) #define HAS_BUFFER (PY_MAJOR_VERSION < 3)
#define HAS_MEMORYVIEW (PY_MAJOR_VERSION > 2 || PY_MINOR_VERSION >= 6)
/* binary_quote - do the quote process on plain and unicode strings */ /* binary_quote - do the quote process on plain and unicode strings */
@ -58,10 +57,8 @@ binary_quote(binaryObject *self)
Py_ssize_t buffer_len; Py_ssize_t buffer_len;
size_t len = 0; size_t len = 0;
PyObject *rv = NULL; PyObject *rv = NULL;
#if HAS_MEMORYVIEW
Py_buffer view; Py_buffer view;
int got_view = 0; int got_view = 0;
#endif
/* Allow Binary(None) to work */ /* Allow Binary(None) to work */
if (self->wrapped == Py_None) { if (self->wrapped == Py_None) {
@ -71,8 +68,6 @@ binary_quote(binaryObject *self)
} }
/* if we got a plain string or a buffer we escape it and save the buffer */ /* if we got a plain string or a buffer we escape it and save the buffer */
#if HAS_MEMORYVIEW
if (PyObject_CheckBuffer(self->wrapped)) { if (PyObject_CheckBuffer(self->wrapped)) {
if (0 > PyObject_GetBuffer(self->wrapped, &view, PyBUF_CONTIG_RO)) { if (0 > PyObject_GetBuffer(self->wrapped, &view, PyBUF_CONTIG_RO)) {
goto exit; goto exit;
@ -81,7 +76,6 @@ binary_quote(binaryObject *self)
buffer = (const char *)(view.buf); buffer = (const char *)(view.buf);
buffer_len = view.len; buffer_len = view.len;
} }
#endif
#if HAS_BUFFER #if HAS_BUFFER
if (!buffer && (Bytes_Check(self->wrapped) || PyBuffer_Check(self->wrapped))) { if (!buffer && (Bytes_Check(self->wrapped) || PyBuffer_Check(self->wrapped))) {
@ -114,9 +108,7 @@ binary_quote(binaryObject *self)
exit: exit:
if (to) { PQfreemem(to); } if (to) { PQfreemem(to); }
#if HAS_MEMORYVIEW
if (got_view) { PyBuffer_Release(&view); } if (got_view) { PyBuffer_Release(&view); }
#endif
/* if the wrapped object is not bytes or a buffer, this is an error */ /* if the wrapped object is not bytes or a buffer, this is an error */
if (!rv && !PyErr_Occurred()) { if (!rv && !PyErr_Occurred()) {

View File

@ -341,16 +341,13 @@ adapters_init(PyObject *module)
} }
#endif #endif
#if PY_MAJOR_VERSION >= 3 || PY_MINOR_VERSION >= 6
if (0 > microprotocols_add(&PyByteArray_Type, NULL, (PyObject*)&binaryType)) { if (0 > microprotocols_add(&PyByteArray_Type, NULL, (PyObject*)&binaryType)) {
goto exit; goto exit;
} }
#endif
#if PY_MAJOR_VERSION >= 3 || PY_MINOR_VERSION >= 7
if (0 > microprotocols_add(&PyMemoryView_Type, NULL, (PyObject*)&binaryType)) { if (0 > microprotocols_add(&PyMemoryView_Type, NULL, (PyObject*)&binaryType)) {
goto exit; goto exit;
} }
#endif
if (0 > microprotocols_add(&PyList_Type, NULL, (PyObject*)&listType)) { if (0 > microprotocols_add(&PyList_Type, NULL, (PyObject*)&listType)) {
goto exit; goto exit;