File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,14 @@ def inherited(subclass)
20
20
subclass . instance_variable_set ( :@__pyptr__ , __pyptr__ )
21
21
end
22
22
23
- def new ( *args )
24
- wrap_pyptr ( LibPython ::Helpers . call_object ( __pyptr__ , *args ) )
23
+ def new ( *args , &b )
24
+ wrap_pyptr ( LibPython ::Helpers . call_object ( __pyptr__ , *args ) ) . tap do |obj |
25
+ obj . instance_eval { initialize ( &b ) }
26
+ end
25
27
end
26
28
27
29
def wrap_pyptr ( pyptr )
28
- return pyptr if pyptr . kind_of? self
30
+ return pyptr if pyptr . class <= self
29
31
pyptr = pyptr . __pyptr__ if pyptr . kind_of? PyObjectWrapper
30
32
unless pyptr . kind_of? PyPtr
31
33
raise TypeError , "unexpected argument type #{ pyptr . class } (expected PyCall::PyPtr)"
Original file line number Diff line number Diff line change 13
13
Class . new ( superclass_wrapper )
14
14
end
15
15
16
+ it 'is an instance of subclass' do
17
+ expect ( subclass . new . class ) . to eq ( subclass )
18
+ end
19
+
16
20
it 'calls __init__ of superclass' do
17
21
a = subclass . new ( 1 , 2 , 3 )
18
22
expect ( a . init_args . to_a ) . to eq ( [ 1 , 2 , 3 ] )
You can’t perform that action at this time.
0 commit comments