@@ -7,16 +7,9 @@ Distributed under the terms of the BSD Simplified License.
77The full license is in the LICENSE file, distributed with this software.
88*/
99
10+ #define PY_SSIZE_T_CLEAN
1011#include <Python.h>
1112
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-
2013#ifndef Py_TPFLAGS_HAVE_GETCHARBUFFER
2114#define Py_TPFLAGS_HAVE_GETCHARBUFFER 0
2215#endif // Py_TPFLAGS_HAVE_GETCHARBUFFER
@@ -45,8 +38,8 @@ static int
4538stolenbuf_getbuffer (stolenbufobject * self , Py_buffer * view , int flags ) {
4639 return PyBuffer_FillInfo (view ,
4740 (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 ),
5043 0 , /* not readonly */
5144 flags );
5245}
@@ -128,15 +121,14 @@ static PyObject*
128121move_into_mutable_buffer (PyObject * self , PyObject * bytes_rvalue ) {
129122 stolenbufobject * ret ;
130123
131- if (!PyString_CheckExact (bytes_rvalue )) {
124+ if (!PyBytes_CheckExact (bytes_rvalue )) {
132125 PyErr_SetString (PyExc_TypeError ,
133126 "stolenbuf can only steal from bytes objects" );
134127 return NULL ;
135128 }
136129
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
140132 PyErr_SetObject (badmove , bytes_rvalue );
141133 return NULL ;
142134 }
0 commit comments