summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2025-02-04 17:03:22 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-02-05 07:36:59 +0900
commit02a9c05e3ecc5b4a382ca9c7ca3e4adb79844bc2 (patch)
treef2ac198b9a8742e363893f46f456fa8c944459bf
parent62b87921090b09416a7846c865f23e2a19a448aa (diff)
Handle failing case to load win32/registry
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12616
-rw-r--r--ext/win32/lib/win32/resolv.rb29
1 files changed, 14 insertions, 15 deletions
diff --git a/ext/win32/lib/win32/resolv.rb b/ext/win32/lib/win32/resolv.rb
index d06658f0aa..94c1f17c1b 100644
--- a/ext/win32/lib/win32/resolv.rb
+++ b/ext/win32/lib/win32/resolv.rb
@@ -4,13 +4,8 @@
=end
-require 'win32/registry'
-
module Win32
module Resolv
- API = Registry::API
- Error = Registry::Error
-
def self.get_hosts_path
path = get_hosts_dir
path = File.expand_path('hosts', path)
@@ -47,20 +42,24 @@ module Win32
# Windows NT
#====================================================================
module Resolv
- module SZ
- refine Registry do
- # ad hoc workaround for broken registry
- def read_s(key)
- type, str = read(key)
- unless type == Registry::REG_SZ
- warn "Broken registry, #{name}\\#{key} was #{Registry.type2name(type)}, ignored"
- return String.new
+ begin
+ require 'win32/registry'
+ module SZ
+ refine Registry do
+ # ad hoc workaround for broken registry
+ def read_s(key)
+ type, str = read(key)
+ unless type == Registry::REG_SZ
+ warn "Broken registry, #{name}\\#{key} was #{Registry.type2name(type)}, ignored"
+ return String.new
+ end
+ str
end
- str
end
end
+ using SZ
+ rescue LoadError
end
- using SZ
TCPIP_NT = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'