[pypy-issue] Issue #3166: Wrong exception when calling `str` on an `integer` with an invalid encoding (pypy/pypy)

Roy Williams issues-reply at bitbucket.org
Thu Feb 6 18:38:09 EST 2020


New issue 3166: Wrong exception when calling `str` on an `integer` with an invalid encoding
https://bitbucket.org/pypy/pypy/issues/3166/wrong-exception-when-calling-str-on-an

Roy Williams:

‌

```
$ pypy3 -c "str(1234, 'text')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
LookupError: unknown encoding: text
```

```
$ python3 -c "str(1234, 'text')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: decoding to str: need a bytes-like object, int found
```

This seems related to [https://bitbucket.org/pypy/pypy/issues/2866/36-wrong-exception-while-calling-str-on](https://bitbucket.org/pypy/pypy/issues/2866/36-wrong-exception-while-calling-str-on)

This is breaking `flask_restful` with pypy - [https://github.com/flask-restful/flask-restful/blob/master/flask\_restful/reqparse.py#L147-L156](https://github.com/flask-restful/flask-restful/blob/master/flask_restful/reqparse.py#L147-L156) .  If `self.type` is a `str` `flask_restful` is expecting to get a `TypeError` as it tries a variety of different ways to parse the argument.




More information about the pypy-issue mailing list