🌐 AI搜索 & 代理 主页
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
7 changes: 6 additions & 1 deletion lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,12 @@ def _strip_comment(s):
elif 0 <= hash_pos < quote_pos:
return s[:hash_pos].strip()
else:
pos = s.find('"', quote_pos + 1) + 1 # behind closing quote
closing_quote_pos = s.find('"', quote_pos + 1)
if closing_quote_pos < 0:
raise ValueError(
f"Missing closing quote in: {s!r}. If you need a double-"
'quote inside a string, use escaping: e.g. "the \" char"')
pos = closing_quote_pos + 1 # behind closing quote


def is_writable_file_like(obj):
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/tests/test_cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,11 @@ def test_strip_comment(line, result):
assert cbook._strip_comment(line) == result


def test_strip_comment_invalid():
with pytest.raises(ValueError, match="Missing closing quote"):
cbook._strip_comment('grid.color: "aa')


def test_sanitize_sequence():
d = {'a': 1, 'b': 2, 'c': 3}
k = ['a', 'b', 'c']
Expand Down