@@ -9,17 +9,13 @@ The full license is in the LICENSE file, distributed with this software.
99
1010#include <Python.h>
1111
12- #define COMPILING_IN_PY2 (PY_VERSION_HEX <= 0x03000000)
13-
14- #if !COMPILING_IN_PY2
1512/* alias this because it is not aliased in Python 3 */
1613#define PyString_CheckExact PyBytes_CheckExact
1714#define PyString_AS_STRING PyBytes_AS_STRING
1815#define PyString_GET_SIZE PyBytes_GET_SIZE
1916
2017/* in python 3, we cannot intern bytes objects so this is always false */
2118#define PyString_CHECK_INTERNED (cs ) 0
22- #endif // !COMPILING_IN_PY2
2319
2420#ifndef Py_TPFLAGS_HAVE_GETCHARBUFFER
2521#define Py_TPFLAGS_HAVE_GETCHARBUFFER 0
@@ -55,45 +51,11 @@ stolenbuf_getbuffer(stolenbufobject *self, Py_buffer *view, int flags) {
5551 flags );
5652}
5753
58- #if COMPILING_IN_PY2
59-
60- static Py_ssize_t
61- stolenbuf_getreadwritebuf (stolenbufobject * self ,
62- Py_ssize_t segment , void * * out ) {
63- if (segment != 0 ) {
64- PyErr_SetString (PyExc_SystemError ,
65- "accessing non-existent string segment" );
66- return -1 ;
67- }
68- * out = PyString_AS_STRING (self -> invalid_bytes );
69- return PyString_GET_SIZE (self -> invalid_bytes );
70- }
71-
72- static Py_ssize_t
73- stolenbuf_getsegcount (stolenbufobject * self , Py_ssize_t * len ) {
74- if (len ) {
75- * len = PyString_GET_SIZE (self -> invalid_bytes );
76- }
77- return 1 ;
78- }
79-
80- static PyBufferProcs stolenbuf_as_buffer = {
81- (readbufferproc ) stolenbuf_getreadwritebuf ,
82- (writebufferproc ) stolenbuf_getreadwritebuf ,
83- (segcountproc ) stolenbuf_getsegcount ,
84- (charbufferproc ) stolenbuf_getreadwritebuf ,
85- (getbufferproc ) stolenbuf_getbuffer ,
86- };
87-
88- #else // Python 3
89-
9054static PyBufferProcs stolenbuf_as_buffer = {
9155 (getbufferproc ) stolenbuf_getbuffer ,
9256 NULL ,
9357};
9458
95- #endif // COMPILING_IN_PY2
96-
9759PyDoc_STRVAR (stolenbuf_doc ,
9860 "A buffer that is wrapping a stolen bytes object's buffer." );
9961
@@ -200,15 +162,13 @@ static PyMethodDef methods[] = {
200162
201163#define MODULE_NAME "pandas.util._move"
202164
203- #if !COMPILING_IN_PY2
204165static PyModuleDef move_module = {
205166 PyModuleDef_HEAD_INIT ,
206167 MODULE_NAME ,
207168 NULL ,
208169 -1 ,
209170 methods ,
210171};
211- #endif // !COMPILING_IN_PY2
212172
213173PyDoc_STRVAR (
214174 badmove_doc ,
@@ -225,14 +185,8 @@ PyDoc_STRVAR(
225185 "pandas.util._move.move_into_mutable_buffer\n" );
226186
227187PyMODINIT_FUNC
228- #if !COMPILING_IN_PY2
229188#define ERROR_RETURN NULL
230- PyInit__move (void )
231- #else
232- #define ERROR_RETURN
233- init_move (void )
234- #endif // !COMPILING_IN_PY2
235- {
189+ PyInit__move (void ) {
236190 PyObject * m ;
237191
238192 if (!(badmove = PyErr_NewExceptionWithDoc ("pandas.util._move.BadMove" ,
@@ -246,12 +200,7 @@ init_move(void)
246200 return ERROR_RETURN ;
247201 }
248202
249- #if !COMPILING_IN_PY2
250- if (!(m = PyModule_Create (& move_module )))
251- #else
252- if (!(m = Py_InitModule (MODULE_NAME , methods )))
253- #endif // !COMPILING_IN_PY2
254- {
203+ if (!(m = PyModule_Create (& move_module ))) {
255204 return ERROR_RETURN ;
256205 }
257206
@@ -267,7 +216,5 @@ init_move(void)
267216 return ERROR_RETURN ;
268217 }
269218
270- #if !COMPILING_IN_PY2
271219 return m ;
272- #endif // !COMPILING_IN_PY2
273220}
0 commit comments