Skip to content

Commit c8797af

Browse files
committed
cqltypes: fix SyntaxWarning for invalid escape sequence in UDT names
In cqltype_to_python(), double-quoted UDT names containing backslashes (e.g. '"!@#$%^&*()[]\ frozen >>>") were passed to ast.literal_eval without escaping, producing SyntaxWarning on Python 3.12+: SyntaxWarning: "\ " is an invalid escape sequence Escape backslashes before wrapping the token for ast.literal_eval. The reverse operation already exists in python_to_cqltype() at line 159.
1 parent 9c53d78 commit c8797af

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

cassandra/cqltypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def cqltype_to_python(cql_string):
130130
(r'<', lambda s, t: ', ['),
131131
(r'>', lambda s, t: ']'),
132132
(r'[, ]', lambda s, t: t),
133-
(r'".*?"', lambda s, t: "'{}'".format(t)),
133+
(r'".*?"', lambda s, t: "'{}'".format(t.replace('\\', '\\\\'))),
134134
))
135135

136136
scanned_tokens = scanner.scan(cql_string)[0]

0 commit comments

Comments
 (0)