{"action":"created","issue":{"url":"https://api.github.com/repos/jorgenschaefer/elpy/issues/593","labels_url":"https://api.github.com/repos/jorgenschaefer/elpy/issues/593/labels{/name}","comments_url":"https://api.github.com/repos/jorgenschaefer/elpy/issues/593/comments","events_url":"https://api.github.com/repos/jorgenschaefer/elpy/issues/593/events","html_url":"https://github.com/jorgenschaefer/elpy/issues/593","id":88575093,"number":593,"title":"\"The backend encountered an unexpected error... KeyError: u'self'\"","user":{"login":"njsmith","id":609896,"avatar_url":"https://avatars.githubusercontent.com/u/609896?v=3","gravatar_id":"","url":"https://api.github.com/users/njsmith","html_url":"https://github.com/njsmith","followers_url":"https://api.github.com/users/njsmith/followers","following_url":"https://api.github.com/users/njsmith/following{/other_user}","gists_url":"https://api.github.com/users/njsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/njsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njsmith/subscriptions","organizations_url":"https://api.github.com/users/njsmith/orgs","repos_url":"https://api.github.com/users/njsmith/repos","events_url":"https://api.github.com/users/njsmith/events{/privacy}","received_events_url":"https://api.github.com/users/njsmith/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-16T00:24:08Z","updated_at":"2015-06-16T00:24:55Z","closed_at":null,"body":"```\r\nError Message\r\n\r\nu'self'\r\n\r\nConfiguration\r\n\r\nVirtualenv........: .user-python2.7-64bit-3 (/home/njs/.user-python2.7-64bit-3)\r\nRPC Python........: 2.7.8 (/home/njs/.user-python2.7-64bit-3/bin/python)\r\nInteractive Python: ipython (/home/njs/.user-python2.7-64bit-3/bin/ipython)\r\nEmacs.............: 24.4.1\r\nElpy..............: 1.8.0\r\nJedi..............: 0.9.0\r\nRope..............: 0.10.2\r\nImportmagic.......: 0.1.3\r\nSyntax checker....: flake8 (/home/njs/.user-python2.7-64bit-3/bin/flake8)\r\n\r\nTraceback\r\n\r\nTraceback (most recent call last):\r\n  File \"/home/njs/.emacs.d/elpa/elpy-20150502.740/elpy/jedibackend.py\", line 303, in run_with_debug\r\n    return getattr(script, name)()\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/api/__init__.py\", line 185, in completions\r\n    user_stmt = self._parser.user_stmt_with_whitespace()\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/cache.py\", line 143, in wrapper\r\n    result = func(self)\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/user_context.py\", line 303, in user_stmt_with_whitespace\r\n    user_stmt = self.user_stmt()\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/cache.py\", line 143, in wrapper\r\n    result = func(self)\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/user_context.py\", line 293, in user_stmt\r\n    module = self.module()\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/user_context.py\", line 339, in module\r\n    return self._parser().module\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/cache.py\", line 143, in wrapper\r\n    result = func(self)\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/user_context.py\", line 283, in _parser\r\n    parser = FastParser(self._grammar, self._source, self._path)\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/fast.py\", line 109, in __call__\r\n    p.update(source)\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/fast.py\", line 257, in update\r\n    self._parse(source)\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/fast.py\", line 383, in _parse\r\n    line_offset, nodes)\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/fast.py\", line 435, in _get_node\r\n    p = Parser(self._grammar, parser_code, self.module_path, tokenizer=tokenizer)\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/__init__.py\", line 155, in __init__\r\n    self.module = p.parse(self._tokenize(tokenizer))\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/pgen2/parse.py\", line 106, in parse\r\n    if self.addtoken(type, value, prefix, start_pos):\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/pgen2/parse.py\", line 170, in addtoken\r\n    value, start_pos, prefix, self.addtoken)\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/__init__.py\", line 269, in error_recovery\r\n    self._stack_removal(grammar, stack, index + 1, value, start_pos)\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/__init__.py\", line 304, in _stack_removal\r\n    clear_names(children=node[1])\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/__init__.py\", line 294, in clear_names\r\n    clear_names(c.children)\r\n  File \"/home/njs/.user-python2.7-64bit-3/local/lib/python2.7/site-packages/jedi/parser/__init__.py\", line 298, in clear_names\r\n    self._scope_names_stack[-1][c.value].remove(c)\r\nKeyError: u'self'\r\n\r\nJedi Debug Information\r\n\r\nJedi did not emit any debug info.\r\n\r\n```\r\n\r\nReproduction:\r\n\r\n```Python\r\nimport jedi\r\n\r\nsource = '''\\\r\n# This file is part of pycam02ucs\r\n# Copyright (C) 2014 Nathaniel Smith <njs@pobox.com>\r\n# See file LICENSE.txt for license information.\r\n\r\nimport numpy as np\r\nimport collections\r\n\r\nclass PathKeeper(object):\r\n    def __init__(self):\r\n        self._paths = defaultdict(lambda\r\n\r\n    def add_connection(self, source, target, data):\r\n        self._paths[(source, target)] = [data]\r\n        queue = [(source, target, [data])]\r\n        while queue:\r\n            source, target, data = queue.pop()\r\n            current_path = self._paths.get((source, target))\r\n            if current_path is None or len(data) < len(current_path):\r\n                self._paths[(source, target)] = [data]\r\n            \r\n        \r\n\r\n################################################################\r\n\r\nfrom .srgb import sRGB_to_XYZ, XYZ_to_sRGB\r\n\r\ndef _XYZ_to_XYZ(XYZ):\r\n    XYZ = np.asarray(XYZ, dtype=float)\r\n    return XYZ\r\n\r\ndef _XYZ_to_xyY(XYZ):\r\n    XYZ = np.asarray(XYZ, dtype=float)\r\n    norm = np.sum(arr, axis=-1, keepdims=True)\r\n    xy = XYZ[..., :2] / norm\r\n    return np.concatenate((xy, XYZ[..., 2:3]), axis=-1)\r\n\r\ndef _xyY_to_XYZ(xyY):\r\n    xyY = np.asarray(xyY, dtype=float)\r\n    x = xyY[..., 0]\r\n    y = xyY[..., 1]\r\n    Y = xyY[..., 2]\r\n    X = Y / y * x\r\n    Z = Y / y * (1 - x - y)\r\n    return np.concatenate((X[..., np.newaxis],\r\n                           Y[..., np.newaxis],\r\n                           Z[..., np.newaxis]),\r\n                          axis=-1)\r\n\r\nto_XYZ = {\r\n    \"XYZ\": _XYZ_to_XYZ,\r\n    \"xyY\": _xyY_to_XYZ,\r\n    \"sRGB\": _sRGB_to_XYZ,\r\n    }\r\n\r\n_CIECAM02_coordinates = set(\"JChQMsH\")\r\n\r\n# sRGB -> CIECAM02, only one viewing condition possible\r\n#   and maybe want some arbitrary JMhH or something\r\n# also: subset of CIECAM02 -> different subset of CIECAM02\r\n# XYZ, xyY -> CIECAM02 under arbitrary viewing conditions\r\n# CIECAM02 -> CAM02-space,\r\n\r\n# XYZ is 0-100\r\n# CIECAM02 stuff is always 0-100\r\n# CAM02-xxx ditto\r\n# xyY is... what? (0-1, 0-1, 0-100) I guess.\r\n# sRGB is 0-1\r\n\r\n# colorblindness is a perceptual thing, not a light thing, so I guess we apply\r\n# there?\r\n# convert sRGB -> CIECAM02-with-colorblindness, then CIECAM02 -> sRGB? kinda\r\n# weird given that we have the direct matrices, but makes it easier to reason\r\n# about I guess?\r\n\r\ndef convert(arr, start, end, viewing_conditions=ViewingConditions.sRGB):\r\n    pass\r\n'''\r\n\r\nscript = jedi.Script(column=40, source=source, line=10, encoding='utf-8', path=u'/home/njs/pycam02ucs/pycam02ucs/util.py')\r\nscript.completions()\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/jorgenschaefer/elpy/issues/comments/112243503","html_url":"https://github.com/jorgenschaefer/elpy/issues/593#issuecomment-112243503","issue_url":"https://api.github.com/repos/jorgenschaefer/elpy/issues/593","id":112243503,"user":{"login":"njsmith","id":609896,"avatar_url":"https://avatars.githubusercontent.com/u/609896?v=3","gravatar_id":"","url":"https://api.github.com/users/njsmith","html_url":"https://github.com/njsmith","followers_url":"https://api.github.com/users/njsmith/followers","following_url":"https://api.github.com/users/njsmith/following{/other_user}","gists_url":"https://api.github.com/users/njsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/njsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njsmith/subscriptions","organizations_url":"https://api.github.com/users/njsmith/orgs","repos_url":"https://api.github.com/users/njsmith/repos","events_url":"https://api.github.com/users/njsmith/events{/privacy}","received_events_url":"https://api.github.com/users/njsmith/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T00:24:55Z","updated_at":"2015-06-16T00:24:55Z","body":"(I'd just typed the \"lambda\" on the 10th line of the file, when this error message popped up.)"}}