Skip to content

Commit d1910f3

Browse files
jvansantenstefanseefeld
authored andcommitted
Avoid degrading slice to object in generated sig
1 parent c4e3b13 commit d1910f3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/slice.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,14 @@ slice_base::step() const
3434
((PySliceObject*)this->ptr())->step));
3535
}
3636

37+
static struct register_slice_pytype_ptr
38+
{
39+
register_slice_pytype_ptr()
40+
{
41+
const_cast<converter::registration &>(
42+
converter::registry::lookup(boost::python::type_id<boost::python::slice>())
43+
).m_class_object = &PySlice_Type;
44+
}
45+
}register_slice_pytype_ptr_;
46+
3747
} } } // !namespace boost::python::detail

test/slice.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
0
3434
>>> check_slice_get_indices( slice( -2, -5, -2))
3535
6
36+
>>> check_slice_get_indices.__doc__.strip().split('\\n')[0]
37+
'check_slice_get_indices( (slice)arg1) -> int :'
3638
"""
3739

3840
# Performs an affirmative and negative argument resolution check.

0 commit comments

Comments
 (0)