Skip to content

Commit d4faa16

Browse files
authored
1 parent ee87412 commit d4faa16

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

test/test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ def test_yaml_1_2(self):
317317

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

321322
@unittest.expectedFailure
322323
def test_yaml_1_2_octals(self):

yq/loader.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,33 @@
8787
},
8888
{
8989
"tag": "tag:yaml.org,2002:int",
90-
"regexp": re.compile(r"^(?:|0o[0-7]+|[-+]?(?:[0-9]+)|0x[0-9a-fA-F]+)$", re.X),
90+
"regexp": re.compile(
91+
r"""^(?:
92+
# [-+]?0b[0-1_]+ # (base 2)
93+
[-+]?0[0-7]+ # (base 8)
94+
|[-+]?0o[0-7]+ # (base 8)
95+
|[-+]?(0|[1-9][0-9]*) # (base 10)
96+
# |[-+]?0[0-7_]+ # (base 8)
97+
# |[-+]?0o[0-7_]+ # (base 8)
98+
# |[-+]?(0|[1-9][0-9_]*) # (base 10)
99+
# |[-+]?0x[0-9a-fA-F_]+ # (base 16)
100+
# |[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+ # (base 60)
101+
)$""",
102+
re.X
103+
),
91104
"start_chars": list("-+0123456789"),
92105
},
93106
{
94107
"tag": "tag:yaml.org,2002:float",
95108
"regexp": re.compile(
96-
r"^(?:[-+]?(?:\.[0-9]+|[0-9]+(\.[0-9]*)?)(?:[eE][-+]?[0-9]+)?|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$", # noqa
109+
r"""^(?:
110+
[-+]?([0-9][0-9]*)?\.[0-9.]*([eE][-+][0-9]+)? (base 10)
111+
|[-+]?[0-9][0-9]*(:[0-5]?[0-9])+\.[0-9]* (base 60)
112+
# |[-+]?([0-9][0-9_]*)?\.[0-9.]*([eE][-+][0-9]+)? (base 10)
113+
# |[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\.[0-9_]* (base 60)
114+
|[-+]?\.(inf|Inf|INF) # (infinity)
115+
|\.(nan|NaN|NAN) # (not a number)
116+
)$""",
97117
re.X,
98118
),
99119
"start_chars": list("-+0123456789."),

0 commit comments

Comments
 (0)