New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new reject_bytes option to raise on bytes #266
Conversation
raise TypeError when encountering bytes in ujson.dumps() to prevent unexpected Unicode exceptions in production. Fixes ultrajson#264
was seing ~5% drop in performance without it on 250 strings
Hi, thanks for the PR. This should probably be the new default as it aligns with the standard |
Great! I'm looking forward to that. |
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
@elelay Please could you resolve the merge conflicts? And also have it with No need to support Python 2.7 any more, so The project is now using pytest, so perhaps something like: def test_allow_bytes_default():
data = {"a": b"b"}
with pytest.raises(TypeError):
ujson.dumps(data)
def test_allow_bytes_false():
data = {"a": b"b"}
with pytest.raises(TypeError):
ujson.dumps(data, allow_bytes=False)
def test_allow_bytes_true():
data = {"a": b"b"}
assert ujson.dumps(data, allow_bytes=True) == '{"a":"b"}' Sorry this has taken a while! Because this is a breaking change, it would be good to get this in the 3.0 release due out in the next week or so, if possible. Thank you! |
OK. I'll do this on Friday. |
inverting the logic will break those tests:
|
Thank you! |
raise TypeError when encountering bytes in ujson.dumps() to prevent
unexpected Unicode exceptions in production.
Fixes #264