Attention is currently required from: osmith, laforge, dexter.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34155 )
Change subject: sim-reset-server: fix error printing sw_match_error ......................................................................
Patch Set 2: Code-Review-2
(1 comment)
File contrib/sim-rest-server.py:
https://gerrit.osmocom.org/c/pysim/+/34155/comment/bcf52a25_e516301b PS2, Line 104: ), sw) We actually have a syntax issue here:
``` return str(ApiError("Card Communication Error %s" % failure.value), sw) ```
note that `sw` is actually passed as an argument to `str()`, while it should be passed to the constructor of the `ApiError`! The `str()` function does not concatenate its arguments unlike `print()`, the second argument is actually the `encoding`. With this additional argument `str()` tries to *decode* its first argument instead if calling the `__str__`.
@dexter: can you try applying this patch? I believe it should fix the problem:
``` return str(ApiError("Card Communication Error %s" % failure.value), sw) return str(ApiError("Card Communication Error %s" % failure.value, sw)) ```
You're actually fixing this in the patch, but I suggest to keep the `failure.value`.
I can even reproduce the error mentioned above (similar to yours):
```
e = SwMatchError('feed', '9000') "Card Communication Error %s" % e
'Card Communication Error SW match failed! Expected 9000 and got feed.'
str(e)
'SW match failed! Expected 9000 and got feed.'
str(e, 'feed')
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: decoding to str: need a bytes-like object, SwMatchError found ```