Skip to content

Commit

Permalink
Revert "Do not interpret characters that cannot be parsed in octal as…
Browse files Browse the repository at this point in the history
… int (#176)"

This reverts commit d4faa16.
  • Loading branch information
kislyuk committed Apr 15, 2024
1 parent 28a21a8 commit a688177
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
1 change: 0 additions & 1 deletion test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ def test_yaml_1_2(self):

def test_yaml_1_1_octals(self):
self.assertEqual(self.run_yq("on: -012345", ["-y", "."]), "'on': -5349\n")
self.assertEqual(self.run_yq("on: -012349", ["-y", "."]), "'on': -012349\n")

@unittest.expectedFailure
def test_yaml_1_2_octals(self):
Expand Down
24 changes: 2 additions & 22 deletions yq/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,33 +87,13 @@
},
{
"tag": "tag:yaml.org,2002:int",
"regexp": re.compile(
r"""^(?:
# [-+]?0b[0-1_]+ # (base 2)
[-+]?0[0-7]+ # (base 8)
|[-+]?0o[0-7]+ # (base 8)
|[-+]?(0|[1-9][0-9]*) # (base 10)
# |[-+]?0[0-7_]+ # (base 8)
# |[-+]?0o[0-7_]+ # (base 8)
# |[-+]?(0|[1-9][0-9_]*) # (base 10)
# |[-+]?0x[0-9a-fA-F_]+ # (base 16)
# |[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+ # (base 60)
)$""",
re.X
),
"regexp": re.compile(r"^(?:|0o[0-7]+|[-+]?(?:[0-9]+)|0x[0-9a-fA-F]+)$", re.X),
"start_chars": list("-+0123456789"),
},
{
"tag": "tag:yaml.org,2002:float",
"regexp": re.compile(
r"""^(?:
[-+]?([0-9][0-9]*)?\.[0-9.]*([eE][-+][0-9]+)? (base 10)
|[-+]?[0-9][0-9]*(:[0-5]?[0-9])+\.[0-9]* (base 60)
# |[-+]?([0-9][0-9_]*)?\.[0-9.]*([eE][-+][0-9]+)? (base 10)
# |[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\.[0-9_]* (base 60)
|[-+]?\.(inf|Inf|INF) # (infinity)
|\.(nan|NaN|NAN) # (not a number)
)$""",
r"^(?:[-+]?(?:\.[0-9]+|[0-9]+(\.[0-9]*)?)(?:[eE][-+]?[0-9]+)?|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$", # noqa
re.X,
),
"start_chars": list("-+0123456789."),
Expand Down

0 comments on commit a688177

Please sign in to comment.