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
```



--
To view, visit https://gerrit.osmocom.org/c/pysim/+/34155
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I5a1d19abeb00c2c9dc26517abc44a5c916f2d658
Gerrit-Change-Number: 34155
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-CC: laforge <[email protected]>
Gerrit-CC: osmith <[email protected]>
Gerrit-Attention: osmith <[email protected]>
Gerrit-Attention: laforge <[email protected]>
Gerrit-Attention: dexter <[email protected]>
Gerrit-Comment-Date: Wed, 30 Aug 2023 23:39:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Reply via email to