1111#include " libpy/demangle.h"
1212#include " libpy/detail/autoclass_cache.h"
1313#include " libpy/detail/autoclass_object.h"
14- #include " libpy/detail/autoclass_py2.h"
1514#include " libpy/detail/python.h"
1615#include " libpy/meta.h"
1716#include " libpy/scope_guard.h"
@@ -32,6 +31,7 @@ constexpr void zero_non_pyobject_base(T* b) {
3231}
3332
3433namespace detail {
34+
3535template <typename T>
3636constexpr void nop_clear_base (T*) {}
3737} // namespace detail
@@ -320,7 +320,7 @@ class autoclass_impl {
320320 @return The `tp_flags` to use for this autoclass generated type.
321321 */
322322 static unsigned int flags (int extra_flags, py::borrowed_ref<PyTypeObject> base_type) {
323- unsigned int out = detail::autoclass_base_flags ;
323+ unsigned int out = Py_TPFLAGS_DEFAULT ;
324324 out |= extra_flags;
325325 if (base_type && base_type->tp_flags & Py_TPFLAGS_HAVE_GC) {
326326 out |= Py_TPFLAGS_HAVE_GC;
@@ -1237,11 +1237,8 @@ class autoclass_impl {
12371237 std::stringstream s;
12381238 s << unbox (self);
12391239 std::string data = s.str ();
1240- #if PY_MAJOR_VERSION == 2
1241- return PyString_FromStringAndSize (data.data (), data.size ());
1242- #else
1240+
12431241 return PyUnicode_FromStringAndSize (data.data (), data.size ());
1244- #endif
12451242 }
12461243 catch (const std::exception& e) {
12471244 return raise_from_cxx_exception (e);
@@ -1265,11 +1262,8 @@ class autoclass_impl {
12651262 try {
12661263 auto res = std::invoke (impl, unbox (self));
12671264 std::string data (std::begin (res), std::end (res));
1268- #if PY_MAJOR_VERSION == 2
1269- return PyString_FromStringAndSize (data.data (), data.size ());
1270- #else
1265+
12711266 return PyUnicode_FromStringAndSize (data.data (), data.size ());
1272- #endif
12731267 }
12741268 catch (const std::exception& e) {
12751269 return raise_from_cxx_exception (e);
0 commit comments