Skip to content

Fix loads exception handling. Don't assume exception class can accept…#82

Merged
lelit merged 1 commit into
masterfrom
fix_loads_exception_handling
Sep 30, 2017
Merged

Fix loads exception handling. Don't assume exception class can accept…#82
lelit merged 1 commit into
masterfrom
fix_loads_exception_handling

Conversation

@kenrobbins

Copy link
Copy Markdown
Member

… a single string.

old:

$ python -c "import rapidjson; rapidjson.loads('\"\\\\udc00\"')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: function takes exactly 5 arguments (1 given)

This happens because UnicodeDecodeError is only being passed a string here:

PyErr_Format(etype, fmt, offset, emsg);

for example:

>>> UnicodeDecodeError("foo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function takes exactly 5 arguments (1 given)

new:

$ python -c "import rapidjson; rapidjson.loads('\"\\\\udc00\"')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 0: invalid continuation byte

@kenrobbins kenrobbins force-pushed the fix_loads_exception_handling branch from 471ec4a to c1c7bd4 Compare September 30, 2017 04:27
@lelit lelit merged commit afc811e into master Sep 30, 2017
@lelit

lelit commented Sep 30, 2017

Copy link
Copy Markdown
Contributor

Thank you!

@lelit lelit deleted the fix_loads_exception_handling branch September 30, 2017 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants