File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -412,7 +412,10 @@ def _strip_comment(s):
412412 elif 0 <= hash_pos < quote_pos :
413413 return s [:hash_pos ].strip ()
414414 else :
415- pos = s .find ('"' , quote_pos + 1 ) + 1 # behind closing quote
415+ closing_quote_pos = s .find ('"' , quote_pos + 1 )
416+ if closing_quote_pos < 0 :
417+ raise ValueError (f"Missing closing quote in: { s } " )
418+ pos = closing_quote_pos + 1 # behind closing quote
416419
417420
418421def is_writable_file_like (obj ):
Original file line number Diff line number Diff line change @@ -424,6 +424,13 @@ def test_strip_comment(line, result):
424424 assert cbook ._strip_comment (line ) == result
425425
426426
427+ def test_strip_comment_invalid ():
428+ with pytest .raises (ValueError , match = "Missing closing quote" ):
429+ cbook ._strip_comment ('grid.color: "aa' )
430+ with pytest .raises (ValueError , match = "Missing closing quote" ):
431+ cbook ._strip_comment ('grid.color: "aa' )
432+
433+
427434def test_sanitize_sequence ():
428435 d = {'a' : 1 , 'b' : 2 , 'c' : 3 }
429436 k = ['a' , 'b' , 'c' ]
You can’t perform that action at this time.
0 commit comments