Wrong exception when calling `str` on an `integer` with an invalid encoding

Create issue
Issue #3166 resolved
Roy Williams created an issue

$ 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

This is breaking flask_restful with pypy - 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.

Comments (1)

  1. Log in to comment