Backport #6578
closed(Ruby 1.9.2-p290) Built-in JSON library fails if "Parser" is defined at top level
Description
To duplicate:
class Parser
end
require 'json'
The culprit is line 27 of common/json.rb:
remove_const :Parser if const_defined? :Parser
#const_defined? returns true even if Parser is defined at the top level, not within JSON. In this case, #remove_const fails with an exception. A possible fix would be:
remove_const :Parser if constants.include? :Parser
Updated by alexdowad (Alex Dowad) almost 12 years ago
By the way, I haven't checked whether this works on Ruby 1.9.3... I am (sadly) stuck developing on Windows and can't install multiple versions of Ruby without RVM.
Updated by naruse (Yui NARUSE) almost 12 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport192
- Target version deleted (
1.9.2)
Updated by jonforums (Jon Forums) almost 12 years ago
By the way, I haven't checked whether this works on Ruby 1.9.3... I am (sadly) stuck developing on Windows and can't install multiple versions of Ruby without RVM.
Be happy...test with multiple roobies on windows using pik: https://github.com/vertiginous/pik
C:\Users\Jon>pik ls
167: jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) Client ...
187: ruby 1.8.7 (2012-02-08 patchlevel 358) [i386-mingw32]
193: ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
- 193: ruby 1.9.3p235 (2012-06-05 revision 35917) [i386-mingw32]
193: tcs-ruby 1.9.3p231 (2012-05-25, TCS patched 2012-05-27) [i386-mingw32]
200: ruby 2.0.0dev (2012-06-11 trunk 36028) [i386-mingw32]
C:\Users\Jon>pik ruby -e "puts 'hi ruby'"
jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) Client VM 1.7.0_04) [Windows 7-x86-java]
hi ruby
ruby 1.8.7 (2012-02-08 patchlevel 358) [i386-mingw32]
hi ruby
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
hi ruby
ruby 1.9.3p235 (2012-06-05 revision 35917) [i386-mingw32]
hi ruby
tcs-ruby 1.9.3p231 (2012-05-25, TCS patched 2012-05-27) [i386-mingw32]
hi ruby
ruby 2.0.0dev (2012-06-11 trunk 36028) [i386-mingw32]
hi ruby
Updated by naruse (Yui NARUSE) almost 8 years ago
- Status changed from Open to Rejected