Skip to content

Commit de23e48

Browse files
authored
Fix parse errors when single quotes are present in a table name (#71)
Fixes #70
1 parent f90b668 commit de23e48

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
['Special "table"']
2+
foo = "bar"
3+
4+
["BJ's Restaurant"]
5+
account = "dining"

tests/test_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def json_serial(obj):
5353
"newline_in_strings",
5454
"preserve_quotes_in_string",
5555
"string_slash_whitespace_newline",
56+
"table_names_with_string_delimiters",
5657
],
5758
)
5859
def test_parse_can_parse_valid_toml_files(example, example_name):

tomlkit/parser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ def _split_table_name(self, name): # type: (str) -> Generator[Key]
219219
continue
220220
elif c in {"'", '"'}:
221221
if in_name:
222-
if t == KeyType.Literal and c == '"':
222+
if (
223+
t == KeyType.Literal
224+
and c == '"'
225+
or t == KeyType.Basic
226+
and c == "'"
227+
):
223228
current += c
224229
continue
225230

0 commit comments

Comments
 (0)