Skip to content

Commit fac80b2

Browse files
author
guido.van.rossum
committed
Hopeful fix for issue 1878: remove Py_TPFLAGS_HAVE_VERSION_TAG from
Py_TPFLAGS_DEFAULT when not building the core. git-svn-id: http://svn.python.org/projects/python/trunk@65874 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 8bfa487 commit fac80b2

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

Include/object.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, char **);
162162
/* Py3k buffer interface */
163163

164164
typedef struct bufferinfo {
165-
void *buf;
165+
void *buf;
166166
PyObject *obj; /* borrowed reference */
167167
Py_ssize_t len;
168-
Py_ssize_t itemsize; /* This is Py_ssize_t so it can be
168+
Py_ssize_t itemsize; /* This is Py_ssize_t so it can be
169169
pointed to by strides in simple case.*/
170170
int readonly;
171171
int ndim;
@@ -296,7 +296,7 @@ typedef struct {
296296
segcountproc bf_getsegcount;
297297
charbufferproc bf_getcharbuffer;
298298
getbufferproc bf_getbuffer;
299-
releasebufferproc bf_releasebuffer;
299+
releasebufferproc bf_releasebuffer;
300300
} PyBufferProcs;
301301

302302

@@ -530,6 +530,12 @@ Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value.
530530
531531
Code can use PyType_HasFeature(type_ob, flag_value) to test whether the
532532
given type object has a specified feature.
533+
534+
NOTE: when building the core, Py_TPFLAGS_DEFAULT includes
535+
Py_TPFLAGS_HAVE_VERSION_TAG; outside the core, it doesn't. This is so
536+
that extensions that modify tp_dict of their own types directly don't
537+
break, since this was allowed in 2.5. In 3.0 they will have to
538+
manually remove this flag though!
533539
*/
534540

535541
/* PyBufferProcs contains bf_getcharbuffer */
@@ -606,7 +612,7 @@ given type object has a specified feature.
606612
#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1L<<30)
607613
#define Py_TPFLAGS_TYPE_SUBCLASS (1L<<31)
608614

609-
#define Py_TPFLAGS_DEFAULT ( \
615+
#define Py_TPFLAGS_DEFAULT_EXTERNAL ( \
610616
Py_TPFLAGS_HAVE_GETCHARBUFFER | \
611617
Py_TPFLAGS_HAVE_SEQUENCE_IN | \
612618
Py_TPFLAGS_HAVE_INPLACEOPS | \
@@ -616,8 +622,15 @@ given type object has a specified feature.
616622
Py_TPFLAGS_HAVE_CLASS | \
617623
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \
618624
Py_TPFLAGS_HAVE_INDEX | \
619-
Py_TPFLAGS_HAVE_VERSION_TAG | \
620-
0)
625+
0)
626+
#define Py_TPFLAGS_DEFAULT_CORE (Py_TPFLAGS_DEFAULT_EXTERNAL | \
627+
Py_TPFLAGS_HAVE_VERSION_TAG)
628+
629+
#ifdef Py_BUILD_CORE
630+
#define Py_TPFLAGS_DEFAULT Py_TPFLAGS_DEFAULT_CORE
631+
#else
632+
#define Py_TPFLAGS_DEFAULT Py_TPFLAGS_DEFAULT_EXTERNAL
633+
#endif
621634

622635
#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0)
623636
#define PyType_FastSubclass(t,f) PyType_HasFeature(t,f)

0 commit comments

Comments
 (0)