UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 14: ordinal not in range(128)
See original GitHub issueHi!
I’m getting the error above when running a simple pynetdicom storage SCP.
I’m a bit new to python so it is sure to be a simple thing. Have been googling around for a while now without luck. Any help would really welcome!
from pynetdicom import (
AE, debug_logger, evt, AllStoragePresentationContexts,
ALL_TRANSFER_SYNTAXES
)
debug_logger()
def handle_store(event):
"""Handle EVT_C_STORE events."""
ds = event.dataset(encoding="utf-8")
return 0x0000
handlers = [(evt.EVT_C_STORE, handle_store)]
ae = AE(ae_title=b'TEST')
storage_sop_classes = [
cx.abstract_syntax for cx in AllStoragePresentationContexts
]
for uid in storage_sop_classes:
ae.add_supported_context(uid, ALL_TRANSFER_SYNTAXES)
ae.start_server(('', 11112), block=False, evt_handlers=handlers)
And the error:
E: Unable to decode the received PDU data
E: 'ascii' codec can't decode byte 0xe2 in position 14: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/pynetdicom/dul.py", line 301, in _read_pdu_data
pdu, event = self._decode_pdu(bytestream)
File "/usr/local/lib/python3.8/dist-packages/pynetdicom/dul.py", line 133, in _decode_pdu
pdu.decode(bytestream)
File "/usr/local/lib/python3.8/dist-packages/pynetdicom/pdu.py", line 83, in decode
self, attr_name, func(bytestream[sl], *args)
File "/usr/local/lib/python3.8/dist-packages/pynetdicom/pdu.py", line 283, in _wrap_generate_items
item.decode(item_bytes)
File "/usr/local/lib/python3.8/dist-packages/pynetdicom/pdu_items.py", line 93, in decode
setattr(self, attr_name, func(bytestream[sl], *args))
File "/usr/local/lib/python3.8/dist-packages/pynetdicom/pdu_items.py", line 307, in _wrap_generate_items
item.decode(item_bytes)
File "/usr/local/lib/python3.8/dist-packages/pynetdicom/pdu_items.py", line 93, in decode
setattr(self, attr_name, func(bytestream[sl], *args))
File "/usr/local/lib/python3.8/dist-packages/pynetdicom/pdu_items.py", line 1386, in abstract_syntax_name
value = UID(value.decode('ascii'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 14: ordinal not in range(128)
D: Abort Parameters:
D: =========================== OUTGOING A-ABORT PDU ===========================
D: Abort Source: DUL service-user
D: Abort Reason: No reason given
D: ============================= END A-ABORT PDU ==============================
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
'ascii' codec can't decode byte 0xe2 in position 13: ordinal not ...
The file is being read as a bunch of str s, but it should be unicode s. Python tries to implicitly convert, but...
Read more >'ascii' codec can't decode byte 0xe2 in position 5599 ... - GitHub
UnicodeDecodeError : 'ascii' codec can't decode byte 0xe2 in position 5599: ordinal not in range(128) #87.
Read more >UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in ...
Scanning host fails with error using VUM : Cannot run upgrade script on host | UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in ......
Read more >'ascii' codec can't decode byte 0xe4 in position 11: ordinal not ...
Turns out the root cause of this issue is that the new pyparted build's python modules return unicode objects instead of (byte) strings...
Read more >3924 (Caught an exception while rendering: 'ascii' codec can't ...
UnicodeDecodeError at /admin/articulos/articulo/add/ 'ascii' codec can't decode byte 0xc3 in position 8: ordinal not in range(128) Request Method: GET ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why have you done
ds = event.dataset(encoding="utf-8")
? It should be justevent.dataset
.Anyway, it seems like whatever you’re associating with is using non-conformant UIDs (they’re supposed to be encoded as ASCII). Could you bind the following to
EVT_DATA_RECV
and post the output?Hi!
I’m not aware if any other solution. For me, this simple and crude node is working with OsiriX:
Running this in this conda env in macOS: