{"issue":{"created_at":"2011-11-24T18:15:08Z","state":"closed","updated_at":"2011-11-24T21:50:59Z","user":{"gravatar_id":"f0e286ba0482e57904e89e753a4b36e6","id":59575,"url":"https://api.github.com/users/wolever","login":"wolever","avatar_url":"https://secure.gravatar.com/avatar/f0e286ba0482e57904e89e753a4b36e6?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":3,"body":"When `jsonlib` is installed, the notepad crashes with a `TypeError`:\r\n\r\n```\r\nTraceback (most recent call last):\r\n...\r\n  File \"/Users/wolever/code/sandbox/env/sandbox/lib/python2.6/site-packages/IPython/zmq/kernelmanager.py\", line 752, in start_kernel\r\n    self.write_connection_file()\r\n  File \"/Users/wolever/code/sandbox/env/sandbox/lib/python2.6/site-packages/IPython/zmq/kernelmanager.py\", line 716, in write_connection_file\r\n    shell_port=self.shell_port, hb_port=self.hb_port)\r\n  File \"/Users/wolever/code/sandbox/env/sandbox/lib/python2.6/site-packages/IPython/zmq/entry_point.py\", line 86, in write_connection_file\r\n    f.write(json.dumps(cfg, indent=2))\r\n  File \"/Users/wolever/code/sandbox/env/sandbox/lib/python2.6/site-packages/zmq/utils/jsonapi.py\", line 67, in jsonlib_dumps\r\n    return _squash_unicode(jsonmod.dumps(o,**kwargs))\r\n  File \"/Users/wolever/code/sandbox/env/sandbox/lib/python2.6/site-packages/jsonlib.py\", line 799, in write\r\n    return write_impl (value, sort_keys, validate_indent (indent), ascii_only,\r\n  File \"/Users/wolever/code/sandbox/env/sandbox/lib/python2.6/site-packages/jsonlib.py\", line 812, in validate_indent\r\n    raise TypeError (\"Only whitespace may be used for indentation.\")\r\nTypeError: Only whitespace may be used for indentation.\r\n```\r\n\r\nIt looks like this is because `jsonlib` expects the `indent` argument to be string, while the stdlib's `json` expects `indent` to be a number. The offending code is below:\r\n\r\n```\r\n> /Users/wolever/code/sandbox/env/sandbox/lib/python2.6/site-packages/IPython/zmq/entry_point.py(86)write_connection_file()\r\n-> f.write(json.dumps(cfg, indent=2))\r\n(Pdb) list\r\n 81  \t              )\r\n 82  \t    cfg['ip'] = ip\r\n 83  \t    cfg['key'] = bytes_to_str(key)\r\n 84  \t    \r\n 85  \t    with open(fname, 'wb') as f:\r\n 86  ->\t        f.write(json.dumps(cfg, indent=2))\r\n 87  \t    \r\n 88  \t    return fname, cfg\r\n 89  \t    \r\n 90  \t\r\n 91  \tdef base_launch_kernel(code, fname, stdin=None, stdout=None, stderr=None,\r\n```\r\n\r\nThe above is Python 2.6.7 on OS X 10.7 with jsonlib 1.6.1.\r\n\r\nUninstalling `jsonlib` (presumably forcing a fallback to stdlib `json`?) fixes this issue.","assignee":null,"id":2343981,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":1037,"labels":[],"title":"notepad + jsonlib: TypeError: Only whitespace may be used for indentation.","closed_at":"2011-11-24T21:27:27Z","html_url":"https://github.com/ipython/ipython/issues/1037","url":"https://api.github.com/repos/ipython/ipython/issues/1037","milestone":null},"action":"created","comment":{"created_at":"2011-11-24T21:50:59Z","updated_at":"2011-11-24T21:50:59Z","user":{"gravatar_id":"d5b897c37001627c2e3ad3c1e8a7e6fb","id":151929,"url":"https://api.github.com/users/minrk","login":"minrk","avatar_url":"https://secure.gravatar.com/avatar/d5b897c37001627c2e3ad3c1e8a7e6fb?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"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.\r\n\r\nI might just drop jsonlib support from zmq, but that's irrelevant to IPython, unless we bump the minimum version to 2.1.11.\r\n\r\nIn 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.","id":2869460,"url":"https://api.github.com/repos/ipython/ipython/issues/comments/2869460"}}