From d1910f3d6567a33b7d55d5421297988cf82c6e4d Mon Sep 17 00:00:00 2001 From: Jakob van Santen Date: Wed, 26 Apr 2023 21:03:32 +0200 Subject: [PATCH] Avoid degrading slice to object in generated sig --- src/slice.cpp | 10 ++++++++++ test/slice.py | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/slice.cpp b/src/slice.cpp index ee55f948..5ff56185 100644 --- a/src/slice.cpp +++ b/src/slice.cpp @@ -34,4 +34,14 @@ slice_base::step() const ((PySliceObject*)this->ptr())->step)); } +static struct register_slice_pytype_ptr +{ + register_slice_pytype_ptr() + { + const_cast( + converter::registry::lookup(boost::python::type_id()) + ).m_class_object = &PySlice_Type; + } +}register_slice_pytype_ptr_; + } } } // !namespace boost::python::detail diff --git a/test/slice.py b/test/slice.py index c58bbc02..041934cf 100644 --- a/test/slice.py +++ b/test/slice.py @@ -33,6 +33,8 @@ test passed 0 >>> check_slice_get_indices( slice( -2, -5, -2)) 6 +>>> check_slice_get_indices.__doc__.strip().split('\\n')[0] +'check_slice_get_indices( (slice)arg1) -> int :' """ # Performs an affirmative and negative argument resolution check.