Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ArgumentError with leading and trailing underscores in number str… #438

Merged
merged 1 commit into from
Jun 3, 2020
Merged

Conversation

mthorn
Copy link
Contributor

@mthorn mthorn commented Mar 3, 2020

…ings.

001:0> require 'psych'
true
002:0> '123_'.to_yaml
Traceback (most recent call last):
...
4: from .../lib/ruby/2.7.0/psych/visitors/yaml_tree.rb:279:in visit_String' 3: from .../lib/ruby/2.7.0/psych/scalar_scanner.rb:95:in tokenize'
2: from .../lib/ruby/2.7.0/psych/scalar_scanner.rb:104:in parse_int' 1: from .../lib/ruby/2.7.0/psych/scalar_scanner.rb:104:in Integer'
ArgumentError (invalid value for Integer(): "123_")
003:0> '0x_123'.to_yaml
Traceback (most recent call last):
...
4: from .../lib/ruby/2.7.0/psych/visitors/yaml_tree.rb:279:in visit_String' 3: from .../lib/ruby/2.7.0/psych/scalar_scanner.rb:95:in tokenize'
2: from .../lib/ruby/2.7.0/psych/scalar_scanner.rb:104:in parse_int' 1: from .../lib/ruby/2.7.0/psych/scalar_scanner.rb:104:in Integer'
ArgumentError (invalid value for Integer(): "0x_123")

@jasonswett
Copy link

I have a question about this one. What's the lowest version of Ruby that this bug is fixed for? This bug seems to be present for me in Ruby 2.7.3 and 2.7.4 but not 3.0.2. Is this bug fix in any 2.7.x or do you have to upgrade to 3.x to get the fix?

@casperisfine
Copy link

do you have to upgrade to 3.x to get the fix?

No you can simply add psych to your Gemfile, to replace the version shipped with Ruby.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants