Skip to content

Commit bcfc786

Browse files
committed
fixes for various regressions
1 parent 2bf45a3 commit bcfc786

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

include/pybind11/pybind11.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,8 @@ class generic_type : public object {
686686
/* Create a custom metaclass if requested (used for static properties) */
687687
object metaclass;
688688
if (rec->metaclass) {
689-
std::string name_ = full_name + "__Meta";
690-
object name = reinterpret_steal<object>(PYBIND11_FROM_STRING(name_.c_str()));
689+
std::string meta_name_ = full_name + "__Meta";
690+
object meta_name = reinterpret_steal<object>(PYBIND11_FROM_STRING(meta_name_.c_str()));
691691
metaclass = reinterpret_steal<object>(PyType_Type.tp_alloc(&PyType_Type, 0));
692692
if (!metaclass || !name)
693693
pybind11_fail("generic_type::generic_type(): unable to create metaclass!");
@@ -698,14 +698,13 @@ class generic_type : public object {
698698
turn find the newly constructed type in an invalid state) */
699699

700700
auto type = (PyHeapTypeObject*) metaclass.ptr();
701-
type->ht_name = name.release().ptr();
702-
701+
type->ht_name = meta_name.release().ptr();
703702

704703
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 3
705704
/* Qualified names for Python >= 3.3 */
706705
type->ht_qualname = ht_qualname.release().ptr();
707706
#endif
708-
type->ht_type.tp_name = strdup(name_.c_str());
707+
type->ht_type.tp_name = strdup(meta_name_.c_str());
709708
type->ht_type.tp_base = &PyType_Type;
710709
type->ht_type.tp_flags |= (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE) &
711710
~Py_TPFLAGS_HAVE_GC;
@@ -878,9 +877,8 @@ class generic_type : public object {
878877
PyObject_ClearWeakRefs((PyObject *) self);
879878

880879
PyObject **dict_ptr = _PyObject_GetDictPtr((PyObject *) self);
881-
if (dict_ptr) {
880+
if (dict_ptr)
882881
Py_CLEAR(*dict_ptr);
883-
}
884882
}
885883
Py_TYPE(self)->tp_free((PyObject*) self);
886884
}
@@ -902,12 +900,14 @@ class generic_type : public object {
902900
void *get_buffer_data) {
903901
PyHeapTypeObject *type = (PyHeapTypeObject*) m_ptr;
904902
auto tinfo = detail::get_type_info(&type->ht_type);
905-
if ((type->ht_type.tp_flags & Py_TPFLAGS_HAVE_NEWBUFFER) == 0)
903+
904+
if (!type->ht_type.tp_as_buffer)
906905
pybind11_fail(
907906
"To be able to register buffer protocol support for the type '" +
908907
std::string(tinfo->type->tp_name) +
909908
"' the associated class<>(..) invocation must "
910909
"include the pybind11::buffer_protocol() annotation!");
910+
911911
tinfo->get_buffer = get_buffer;
912912
tinfo->get_buffer_data = get_buffer_data;
913913
}

tests/constructor_stats.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ class ConstructorStats {
158158

159159
// Gets constructor stats from a C++ type
160160
template <typename T> static ConstructorStats& get() {
161+
#if defined(PYPY_VERSION)
161162
gc();
163+
#endif
162164
return get(typeid(T));
163165
}
164166

tests/test_inheritance.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def test_inheritance(msg):
2323

2424
with pytest.raises(TypeError) as excinfo:
2525
dog_bark(polly)
26-
print(excinfo.value)
2726
assert msg(excinfo.value) == """
2827
dog_bark(): incompatible function arguments. The following argument types are supported:
2928
1. (arg0: m.Dog) -> str

0 commit comments

Comments
 (0)