Skip to content

Commit

Permalink
Avoid escaping unicodes in string literals
Browse files Browse the repository at this point in the history
  • Loading branch information
tefra committed Dec 19, 2023
1 parent a903e7a commit 9cc984e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions xsdata/utils/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import re
from typing import Any
from xml.etree.ElementTree import QName
from xml.sax.saxutils import quoteattr


def update(obj: Any, **kwargs: Any):
Expand All @@ -22,7 +21,7 @@ def attrsetter(obj: Any, attr: str, value: Any):

def literal_value(value: Any) -> str:
if isinstance(value, str):
return quoteattr(value.encode("unicode_escape").decode("ASCII"))
return '"' + repr("'\0" + value)[6:]

if isinstance(value, float):
return str(value) if math.isfinite(value) else f'float("{value}")'
Expand Down

0 comments on commit 9cc984e

Please sign in to comment.