@@ -35,9 +35,8 @@ def create_valid_python_identifier(name: str) -> str:
35
35
------
36
36
SyntaxError
37
37
If the returned name is not a Python valid identifier, raise an exception.
38
- This can happen if there is a hashtag in the name, as the tokenizer will
39
- than terminate and not find the backtick.
40
- But also for characters that fall out of the range of (U+0001..U+007F).
38
+ This can happen if the name includes characters that fall out of the range of
39
+ (U+0001..U+007F).
41
40
"""
42
41
if name .isidentifier () and not iskeyword (name ):
43
42
return name
@@ -60,7 +59,6 @@ def create_valid_python_identifier(name: str) -> str:
60
59
# Including quotes works, but there are exceptions.
61
60
"'" : "_SINGLEQUOTE_" ,
62
61
'"' : "_DOUBLEQUOTE_" ,
63
- # Currently not possible. Terminates parser and won't find backtick.
64
62
"#" : "_HASH_" ,
65
63
}
66
64
)
@@ -239,11 +237,11 @@ def _split_by_backtick(s: str) -> list[tuple[bool, str]]:
239
237
break
240
238
241
239
# Quote is unmatched (Bad syntax), or
242
- # Quote is matched, and the next quote is at the end of the string
240
+ # Quote is matched, and the next quote is at the end of s
243
241
if (next_quote_index == - 1 ) or (next_quote_index + 1 == len (s )):
244
242
substrings .append ((False , substring + s [i :]))
245
243
break
246
- # Quote is matched, and the next quote is in the middle of the string
244
+ # Quote is matched, and the next quote is in the middle of s
247
245
else :
248
246
substring += s [i : next_quote_index + 1 ]
249
247
i = next_quote_index + 1
0 commit comments