File tree Expand file tree Collapse file tree 5 files changed +17
-5
lines changed Expand file tree Collapse file tree 5 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ Compatibility:
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
36
* Fix the absolute path of the main script after chdir (#2709 , @eregon ).
37
+ * Fix exception for ` Fiddle::Handle.new ` with a missing library (#2714 , @eregon ).
37
38
38
39
Performance:
39
40
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
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ def report_on_exception=(value)
27
27
end
28
28
end
29
29
30
- ruby_version_is "" ..."2.7" do
30
+ # Compare with SpecVersion directly here so it works even with --unguarded
31
+ if VersionGuard ::FULL_RUBY_VERSION < SpecVersion . new ( '2.7' )
31
32
abort "This version of ruby/spec requires Ruby 2.7+"
32
33
end
33
34
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments