Skip to content

Commit a0768ef

Browse files
authored
Merge pull request #152 from sfo/fix_temperature
illegal temperature will raise ParserError
2 parents 2f1be43 + 953c5eb commit a0768ef

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

metar/Metar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ class ParserError(Exception):
8585
re.VERBOSE,
8686
)
8787
TEMP_RE = re.compile(
88-
r"""^(?P<temp>(M|-)?\d+|//|XX|MM)/
89-
(?P<dewpt>(M|-)?\d+|//|XX|MM)?\s+""",
88+
r"""^(?P<temp>(M|-)?\d{1,2}|//|XX|MM)/
89+
(?P<dewpt>(M|-)?\d{1,2}|//|XX|MM)?\s+""",
9090
re.VERBOSE,
9191
)
9292
PRESS_RE = re.compile(

test/test_metar.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,3 +653,7 @@ def test_cor_auto_mod():
653653
m = Metar.Metar(code, year=2019)
654654

655655
assert m.mod == 'COR AUTO'
656+
657+
658+
def test_issue136_temperature():
659+
raisesParserError("METAR EDDM 022150Z 26006KT CAVOK 201/16")

0 commit comments

Comments
 (0)