Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion can/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def __call__(

def _parse_additional_config(unknown_args: Sequence[str]) -> TAdditionalCliArgs:
for arg in unknown_args:
if not re.match(r"^--[a-zA-Z\-]*?=\S*?$", arg):
if not re.match(r"^--[a-zA-Z][a-zA-Z0-9\-]*=\S*?$", arg):
raise ValueError(f"Parsing argument {arg} failed")

def _split_arg(_arg: str) -> Tuple[str, str]:
Expand Down
4 changes: 4 additions & 0 deletions test/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def test_parse_additional_config(self):
"--receive-own-messages=True",
"--false-boolean=False",
"--offset=1.5",
"--tseg1-abr=127",
]
parsed_args = can.logger._parse_additional_config(unknown_args)

Expand All @@ -170,6 +171,9 @@ def test_parse_additional_config(self):
assert "offset" in parsed_args
assert parsed_args["offset"] == 1.5

assert "tseg1_abr" in parsed_args
assert parsed_args["tseg1_abr"] == 127

with pytest.raises(ValueError):
can.logger._parse_additional_config(["--wrong-format"])

Expand Down
Loading