about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2025-05-30 00:38:26 +0900
committerNguyễn Gia Phong <cnx@loang.net>2025-05-30 00:38:26 +0900
commitdcb363d429b7c284946e04c53f1fc21456e8faff (patch)
tree89f6686a801de3e14630f9ca332a9226ec529dc0 /src
parent82b754bdcf781eabf182293561838fabe21a467d (diff)
downloadscadere-dcb363d429b7c284946e04c53f1fc21456e8faff.tar.gz
Gotta go fast
Coverage does not seem to work with pytest-xdist without pytest-cov.
Diffstat (limited to 'src')
-rw-r--r--src/scadere/listen.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/scadere/listen.py b/src/scadere/listen.py
index 085664d..8d115ae 100644
--- a/src/scadere/listen.py
+++ b/src/scadere/listen.py
@@ -67,12 +67,13 @@ async def describe_status(writer, status):
 
 
 async def write_xml(writer, document):
-    content = strings_from_xml(xml(document), 'unicode',
-                               xml_declaration=True, default_namespace=None)
-    length = len(''.join(content))
-    writer.write(f'Content-Length: {length}\r\n\r\n'.encode())
+    content = tuple(map(str.encode,
+                        strings_from_xml(xml(document), 'unicode',
+                                         xml_declaration=True,
+                                         default_namespace=None)))
+    writer.write(f'Content-Length: {sum(map(len, content))}\r\n\r\n'.encode())
     for part in content:
-        writer.write(part.encode())
+        writer.write(part)
         await writer.drain()