You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our application, we have products with metadata entered by our customers. Some of them need to input Unicode characters, often using the degree symbol (°).
However, when this symbol appears in the metadata value, we encounter the following error:
ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters.
Here is a snippet of code to reproduce this error:
from spyne import Application, ServiceBase, Unicode, rpc
from spyne.model.complex import Array, ComplexModel, XmlAttribute, XmlData
from spyne.protocol.http import HttpRpc
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
class Metadata(ComplexModel):
_type_info = [
("name", XmlAttribute(Unicode(sub_name="name"))),
("value", XmlData(Unicode(sub_name="value"))),
]
class Product(ComplexModel):
_type_info = [
("metadata", Array(Metadata)),
]
class ProductService(ServiceBase):
@rpc(_returns=Product)
def get_product(ctx):
product = Product()
product.metadata = [
Metadata(name="name", value="°"),
]
return product
wsgi_app = WsgiApplication(
Application(
[ProductService],
tns="spyne.examples",
in_protocol=HttpRpc(validator="soft"),
out_protocol=Soap11(),
)
)
In our application, we have products with metadata entered by our customers. Some of them need to input Unicode characters, often using the degree symbol (°).
However, when this symbol appears in the metadata value, we encounter the following error:
ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters
.Here is a snippet of code to reproduce this error:
The text was updated successfully, but these errors were encountered: