Skip to content

Commit 3232c8d

Browse files
committed
Change the return type of PyPtr#__ob_type__
1 parent 9875446 commit 3232c8d

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

ext/pycall/pyptr/pyptr.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pycall_pyptr_get_ob_type(VALUE obj)
284284
{
285285
PyObject* pyobj = get_pyobj_ptr(obj);
286286
if (pyobj) {
287-
VALUE pytypeobj = pycall_pyptr_new((PyObject *)pyobj->ob_type);
287+
VALUE pytypeobj = pycall_pytypeptr_new(pyobj->ob_type);
288288
return pytypeobj;
289289
}
290290
return Qnil;
@@ -381,6 +381,12 @@ pycall_pytypeptr_allocate(VALUE klass)
381381
return TypedData_Wrap_Struct(klass, &pycall_pytypeptr_data_type, NULL);
382382
}
383383

384+
VALUE
385+
pycall_pytypeptr_new(PyTypeObject *pytypeobj)
386+
{
387+
return pycall_pyptr_new_with_klass(cPyTypePtr, (PyObject *)pytypeobj);
388+
}
389+
384390
static VALUE
385391
pycall_pytypeptr_get_ob_size(VALUE obj)
386392
{

ext/pycall/pyptr/pyptr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ PyObject* pycall_pyptr_get_pyobj_ptr(VALUE obj);
299299
VALUE pycall_pyptr_new(PyObject *pyobj);
300300
VALUE pycall_pyptr_incref(VALUE pyptr);
301301
VALUE pycall_pyptr_decref(VALUE pyptr);
302+
VALUE pycall_pytypeptr_new(PyTypeObject *pytypeobj);
302303

303304
#if defined(__cplusplus)
304305
#if 0

spec/pycall/pyptr_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module PyCall
4646

4747
describe '#__ob_type__' do
4848
it 'returns a PyPtr for None' do
49-
expect(PyPtr::None.__ob_type__).to be_a(PyPtr)
49+
expect(PyPtr::None.__ob_type__).to be_a(PyTypePtr)
5050
end
5151
end
5252

0 commit comments

Comments
 (0)