@@ -7,16 +7,9 @@ Distributed under the terms of the BSD Simplified License.
7
7
The full license is in the LICENSE file, distributed with this software.
8
8
*/
9
9
10
+ #define PY_SSIZE_T_CLEAN
10
11
#include <Python.h>
11
12
12
- /* alias this because it is not aliased in Python 3 */
13
- #define PyString_CheckExact PyBytes_CheckExact
14
- #define PyString_AS_STRING PyBytes_AS_STRING
15
- #define PyString_GET_SIZE PyBytes_GET_SIZE
16
-
17
- /* in python 3, we cannot intern bytes objects so this is always false */
18
- #define PyString_CHECK_INTERNED (cs ) 0
19
-
20
13
#ifndef Py_TPFLAGS_HAVE_GETCHARBUFFER
21
14
#define Py_TPFLAGS_HAVE_GETCHARBUFFER 0
22
15
#endif // Py_TPFLAGS_HAVE_GETCHARBUFFER
@@ -45,8 +38,8 @@ static int
45
38
stolenbuf_getbuffer (stolenbufobject * self , Py_buffer * view , int flags ) {
46
39
return PyBuffer_FillInfo (view ,
47
40
(PyObject * ) self ,
48
- (void * ) PyString_AS_STRING (self -> invalid_bytes ),
49
- PyString_GET_SIZE (self -> invalid_bytes ),
41
+ (void * ) PyBytes_AS_STRING (self -> invalid_bytes ),
42
+ PyBytes_GET_SIZE (self -> invalid_bytes ),
50
43
0 , /* not readonly */
51
44
flags );
52
45
}
@@ -128,15 +121,14 @@ static PyObject*
128
121
move_into_mutable_buffer (PyObject * self , PyObject * bytes_rvalue ) {
129
122
stolenbufobject * ret ;
130
123
131
- if (!PyString_CheckExact (bytes_rvalue )) {
124
+ if (!PyBytes_CheckExact (bytes_rvalue )) {
132
125
PyErr_SetString (PyExc_TypeError ,
133
126
"stolenbuf can only steal from bytes objects" );
134
127
return NULL ;
135
128
}
136
129
137
- if (Py_REFCNT (bytes_rvalue ) != 1 || PyString_CHECK_INTERNED (bytes_rvalue )) {
138
- /* there is a reference other than the caller's stack or the string is
139
- interned */
130
+ if (Py_REFCNT (bytes_rvalue ) != 1 ) {
131
+ // there is a reference other than the caller's stack
140
132
PyErr_SetObject (badmove , bytes_rvalue );
141
133
return NULL ;
142
134
}
0 commit comments