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
notepad + jsonlib: TypeError: Only whitespace may be used for indentation. #1037
Comments
Yup, good catch. @minrk, we should probably work around this one in ipython regardless, I'll make the fixes now so that we support jsonlib as well. But ultimately it seems to me the deeper fix should be made in |
OK, I've fixed it quickly, but I noticed that with jsonlib installed, the full test suite doesn't quite complete. @minrk, I had to manually interrupt it at:
I don't know if you want to consider that an issue for us, for zmq or for jsonlib, though, so I won't open another one quite yet. If you think it's on our side, then let's open a new issue for it. |
The goal of jsonlib was to make fast json (stdlib json is extremely slow). but they decided to set their own API. Then, jsonlib2 project was started to bring jsonlib back to API compatibility. I might just drop jsonlib support from zmq, but that's irrelevant to IPython, unless we bump the minimum version to 2.1.11. In the notebook, we can just use stdlib json, because performance is irrelevant. I'll look into the parallel issue, because I can't think of a reason why it shouldn't work. |
Ok, thanks. In the meantime, the workaround I committed means people won't get burned too badly if they have jsonlib installed; I'll leave the decision of what to do in zmq up to you (though dropping jsonlib support seems like the right approach: I looked and the api is so different that any but the most trivial uses are likely to cause problems similar to this one). |
On Nov 24, 2011, at 13:52, Fernando Perezreply@reply.github.com wrote:
Yes, well presumably most users who have chosen to install jsonlib would know how to use it. It's just projects like IPython that have an extra layer of abstraction on zmq, that have to take this kind of thing into account, and even then, only if they want to customize json output (it's irrelevant if extra kwargs aren't being specified).
|
On Thu, Nov 24, 2011 at 1:57 PM, Min RK
True, though sometimes stuff gets pulled in as a dependency, which can |
The main point of the zmq.utils.jsonapi is that it serializes to/from utf8-encoded bytes, and json libraries are inconsistent in whether they deal in unicode or str. If that's not what we need (e.g. talking to files), we should be using the stdlib json. And the fact that jsonlib does not guarantee kwarg equivalence means that anyone using jsonapi with kwargs must take this into account ( The practical result of this is that we (IPython) should essentially never pass kwargs when using zmq.jsonapi. There is exactly one case where we are currently using a kwarg where we should be using zmq.jsonapi at all, and it has always properly handled the difference in jsonlib. The real bug here is that we were using jsonapi in places that don't make any sense. I did find the bug with jsonlib in the test suite - it unserializes floats to decimal.Decimal (?!), so I have to cast it to float before passing it to This may be the last straw for dropping jsonlib support in pyzmq, but that will be irrelevant to IPython until we bump minimum pyzmq version past 2.1.11. A monkeypatch for prohibiting pyzmq from using jsonlib, and forcing fallback to stdlib: import json
from zmq.utils import jsonapi
if jsonapi.jsonmod.__name__ == 'jsonlib':
jsonapi.jsonmod = json But this may not be ideal, as jsonlib is significantly faster than stdlib, and with the small fix in PR #1040, well behaved. |
OK, I like the approach in #1040, so let's go with that. Thanks! |
Note that there seems to be a deeper problem with jsonlib; at least on my system it doesn't pass the full test suite. But with this fix, regular interactive use is now OK. Closes ipython#1037.
When
jsonlib
is installed, the notepad crashes with aTypeError
:It looks like this is because
jsonlib
expects theindent
argument to be string, while the stdlib'sjson
expectsindent
to be a number. The offending code is below:The above is Python 2.6.7 on OS X 10.7 with jsonlib 1.6.1.
Uninstalling
jsonlib
(presumably forcing a fallback to stdlibjson
?) fixes this issue.The text was updated successfully, but these errors were encountered: