File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed
spec/ruby/library/fiddle/handle Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ Compatibility:
33
33
* Implement ` rb_eval_cmd_kw ` to support the ` tk ` gem (#2556 , @aardvark179 ).
34
34
* Fix ` rb_class2name ` to call ` inspect ` on anonymous classes like in CRuby (#2701 , @aardvark179 ).
35
35
* Implement ` rb_ivar_foreach ` to iterate over instance and class variables like in CRuby (#2701 , @aardvark179 ).
36
+ * Fix exception for ` Fiddle::Handle.new ` with a missing library (#2714 , @eregon ).
36
37
37
38
Performance:
38
39
Original file line number Diff line number Diff line change @@ -253,15 +253,16 @@ def self.[](*args)
253
253
RTLD_GLOBAL = Truffle ::Config [ 'platform.dlopen.RTLD_GLOBAL' ]
254
254
255
255
def initialize ( library = nil , flags = RTLD_LAZY | RTLD_GLOBAL )
256
- raise DLError , 'unsupported dlopen flags' if flags != RTLD_LAZY | RTLD_GLOBAL
256
+ raise DLError , 'unsupported dlopen flags' if flags != ( RTLD_LAZY | RTLD_GLOBAL )
257
+
257
258
if library == Truffle ::FiddleBackend ::RTLD_NEXT
258
259
@handle = :rtld_next
259
260
else
260
261
library = nil if library == Truffle ::FiddleBackend ::RTLD_DEFAULT
261
262
begin
262
263
@handle = Primitive . interop_eval_nfi ( library ? "load '#{ library } '" : 'default' )
263
- rescue RuntimeError
264
- raise DLError , "#{ library } : cannot open shared object file: No such file or directory "
264
+ rescue Polyglot :: ForeignException => e
265
+ raise DLError , "#{ e . message } "
265
266
end
266
267
end
267
268
end
Original file line number Diff line number Diff line change
1
+ require_relative '../../../spec_helper'
2
+ require 'fiddle'
3
+
4
+ describe "Fiddle::Handle#initialize" do
5
+ it "raises Fiddle::DLError if the library cannot be found" do
6
+ -> {
7
+ Fiddle ::Handle . new ( "doesnotexist.doesnotexist" )
8
+ } . should raise_error ( Fiddle ::DLError )
9
+ end
10
+ end
You can’t perform that action at this time.
0 commit comments