ruby / uri

URI is a module providing classes to handle Uniform Resource Identifiers
https://ruby.github.io/uri/
Other
79 stars 42 forks source link

Restrict const checks to current namespace to avoid conflict with globals #108

Closed rwstauner closed 1 month ago

rwstauner commented 2 months ago

Getting this error on latest master when a top-level Parser constant is defined before URI is loaded:

$ ruby -Ilib -e 'module Parser; end; require "uri/common"'
/Users/rwstauner/src/github.com/ruby/uri/lib/uri/common.rb:26:in `remove_const': constant URI::Parser not defined (NameError)

    remove_const(:Parser) if defined?(Parser)
    ^^^^^^^^^^^^
        from /Users/rwstauner/src/github.com/ruby/uri/lib/uri/common.rb:26:in `parser='
        from /Users/rwstauner/src/github.com/ruby/uri/lib/uri/common.rb:46:in `<module:URI>'
        from /Users/rwstauner/src/github.com/ruby/uri/lib/uri/common.rb:15:in `<top (required)>'
        from <internal:/Users/rwstauner/.rubies/3.3.0/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
        from <internal:/Users/rwstauner/.rubies/3.3.0/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
        from -e:1:in `<main>'
jeremyevans commented 1 month ago

Good work. Was about to submit the same pull request in response to Ruby bug 20644.

hsbt commented 1 month ago

👍 Thanks!