{"action":"opened","issue":{"url":"https://api.github.com/repos/jorgenschaefer/elpy/issues/718","labels_url":"https://api.github.com/repos/jorgenschaefer/elpy/issues/718/labels{/name}","comments_url":"https://api.github.com/repos/jorgenschaefer/elpy/issues/718/comments","events_url":"https://api.github.com/repos/jorgenschaefer/elpy/issues/718/events","html_url":"https://github.com/jorgenschaefer/elpy/issues/718","id":117209372,"number":718,"title":"\"waf\" with ginormous binary comment: 'latin-1' codec can't encode character u'\\u0186' in position 4152: ordinal not in range(256)","user":{"login":"offby1","id":3145,"avatar_url":"https://avatars.githubusercontent.com/u/3145?v=3","gravatar_id":"","url":"https://api.github.com/users/offby1","html_url":"https://github.com/offby1","followers_url":"https://api.github.com/users/offby1/followers","following_url":"https://api.github.com/users/offby1/following{/other_user}","gists_url":"https://api.github.com/users/offby1/gists{/gist_id}","starred_url":"https://api.github.com/users/offby1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/offby1/subscriptions","organizations_url":"https://api.github.com/users/offby1/orgs","repos_url":"https://api.github.com/users/offby1/repos","events_url":"https://api.github.com/users/offby1/events{/privacy}","received_events_url":"https://api.github.com/users/offby1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-16T20:20:31Z","updated_at":"2015-11-16T20:20:31Z","closed_at":null,"body":"Reproducing this will be a bit involved, since I can't seem to include the complete error message in this bug report (probably because it's so big, or filled with nonprintable characters).  But the steps are pretty straightforward:\r\n\r\n    $ git clone https://gitlab.com/NTPsec/ntpsec.git\r\n    $ git reset --hard 517fa69b41c3f022a402ee3f1b9ba08f87c7a381\r\n    $ cd ntpsec\r\n\r\n    Visit the \"waf\" file.  Scroll down a few pages.\r\n\r\n```\r\nError Message\r\n\r\n'latin-1' codec can't encode character u'\\u0186' in position 4152: ordinal not in range(256)\r\n\r\nConfiguration\r\n\r\nVirtualenv........: None\r\nRPC Python........: 2.7.10 (/usr/bin/python)\r\nInteractive Python: python3 (/usr/local/bin/python3)\r\nEmacs.............: 25.0.50.1\r\nElpy..............: 1.10.0\r\nJedi..............: Not found (0.9.0 available)\r\nRope..............: 0.10.2 (0.10.3 available)\r\nImportmagic.......: 0.1.3\r\nAutopep8..........: 0.1.3\r\nSyntax checker....: Not found (flake8)\r\n\r\nTraceback\r\n\r\nTraceback (most recent call last):\r\n  File \"/Users/erichanchrow/.emacs.d/elpa/elpy-20151101.401/elpy/ropebackend.py\", line 100, in call_rope\r\n    **kwargs)\r\n  File \"/Users/erichanchrow/Library/Python/2.7/lib/python/site-packages/rope-0.10.2-py2.7.egg/rope/contrib/codeassist.py\", line 92, in get_calltip\r\n    pyname = fixer.pyname_at(offset)\r\n  File \"/Users/erichanchrow/Library/Python/2.7/lib/python/site-packages/rope-0.10.2-py2.7.egg/rope/contrib/fixsyntax.py\", line 46, in pyname_at\r\n    pymodule = self.get_pymodule()\r\n  File \"/Users/erichanchrow/Library/Python/2.7/lib/python/site-packages/rope-0.10.2-py2.7.egg/rope/base/utils.py\", line 11, in _wrapper\r\n    setattr(self, name, func(self, *args, **kwds))\r\n  File \"/Users/erichanchrow/Library/Python/2.7/lib/python/site-packages/rope-0.10.2-py2.7.egg/rope/contrib/fixsyntax.py\", line 28, in get_pymodule\r\n    code, resource=self.resource, force_errors=True)\r\n  File \"/Users/erichanchrow/Library/Python/2.7/lib/python/site-packages/rope-0.10.2-py2.7.egg/rope/base/pycore.py\", line 114, in get_string_module\r\n    return PyModule(self, code, resource, force_errors=force_errors)\r\n  File \"/Users/erichanchrow/Library/Python/2.7/lib/python/site-packages/rope-0.10.2-py2.7.egg/rope/base/pyobjectsdef.py\", line 155, in __init__\r\n    source, node = self._init_source(pycore, source, resource)\r\n  File \"/Users/erichanchrow/Library/Python/2.7/lib/python/site-packages/rope-0.10.2-py2.7.egg/rope/base/pyobjectsdef.py\", line 179, in _init_source\r\n    source_bytes = fscommands.unicode_to_file_data(source_code)\r\n  File \"/Users/erichanchrow/Library/Python/2.7/lib/python/site-packages/rope-0.10.2-py2.7.egg/rope/base/fscommands.py\", line 196, in unicode_to_file_data\r\n    return contents.encode(encoding)\r\nUnicodeEncodeError: 'latin-1' codec can't encode character u'\\u0186' in position 4152: ordinal not in range(256)\r\n\r\nRope Debug Information\r\n\r\n```\r\n\r\nReproduction:\r\n\r\n```Python\r\n\r\nsource = '''\r\n#!/usr/bin/env python\r\n# encoding: ISO8859-1\r\n# Thomas Nagy, 2005-2015\r\n\r\n\"\"\"\r\nRedistribution and use in source and binary forms, with or without\r\nmodification, are permitted provided that the following conditions\r\nare met:\r\n\r\n1. Redistributions of source code must retain the above copyright\r\n   notice, this list of conditions and the following disclaimer.\r\n\r\n2. Redistributions in binary form must reproduce the above copyright\r\n   notice, this list of conditions and the following disclaimer in the\r\n   documentation and/or other materials provided with the distribution.\r\n\r\n3. The name of the author may not be used to endorse or promote products\r\n   derived from this software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR \"AS IS\" AND ANY EXPRESS OR\r\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,\r\nINDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r\nSTRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\r\nIN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\nPOSSIBILITY OF SUCH DAMAGE.\r\n\"\"\"\r\n\r\nimport os, sys, inspect\r\n\r\nVERSION=\"1.8.12\"\r\nREVISION=\"f00e5b53f6bbeab1384a38c9cc5d51f7\"\r\nGIT=\"1427497785a594dedeaac09013db635791f068c4\"\r\nINSTALL=''\r\nC1='#+'\r\nC2='#)'\r\nC3='#%'\r\ncwd = os.getcwd()\r\njoin = os.path.join\r\n\r\n\r\nWAF='waf'\r\ndef b(x):\r\n\treturn x\r\nif sys.hexversion>0x300000f:\r\n\tWAF='waf3'\r\n\tdef b(x):\r\n\t\treturn x.encode()\r\n\r\ndef err(m):\r\n\tprint(('\\033[91mError: %s\\033[0m' % m))\r\n\tsys.exit(1)\r\n\r\ndef unpack_wafdir(dir, src):\r\n\tf = open(src,'rb')\r\n\tc = 'corrupt archive (%d)'\r\n\twhile 1:\r\n\t\tline = f.readline()\r\n\t\tif not line: err('run waf-light from a folder containing waflib')\r\n\t\tif line == b('#==>\\n'):\r\n\t\t\ttxt = f.readline()\r\n\t\t\tif not txt: err(c % 1)\r\n\t\t\tif f.readline() != b('#<==\\n'): err(c % 2)\r\n\t\t\tbreak\r\n\tif not txt: err(c % 3)\r\n\ttxt = txt[1:-1].replace(b(C1), b('\\n')).replace(b(C2), b('\\r')).replace(b(C3), b('\\x00'))\r\n\r\n\timport shutil, tarfile\r\n\ttry: shutil.rmtree(dir)\r\n\texcept OSError: pass\r\n\ttry:\r\n\t\tfor x in ('Tools', 'extras'):\r\n\t\t\tos.makedirs(join(dir, 'waflib', x))\r\n\texcept OSError:\r\n\t\terr(\"Cannot unpack waf lib into %s\\nMove waf in a writable directory\" % dir)\r\n\r\n\tos.chdir(dir)\r\n\ttmp = 't.bz2'\r\n\tt = open(tmp,'wb')\r\n\ttry: t.write(txt)\r\n\tfinally: t.close()\r\n\r\n\ttry:\r\n\t\tt = tarfile.open(tmp)\r\n\texcept:\r\n\t\ttry:\r\n\t\t\tos.system('bunzip2 t.bz2')\r\n\t\t\tt = tarfile.open('t')\r\n\t\t\ttmp = 't'\r\n\t\texcept:\r\n\t\t\tos.chdir(cwd)\r\n\t\t\ttry: shutil.rmtree(dir)\r\n\t\t\texcept OSError: pass\r\n\t\t\terr(\"Waf cannot be unpacked, check that bzip2 support is present\")\r\n\r\n\ttry:\r\n\t\tfor x in t: t.extract(x)\r\n\tfinally:\r\n\t\tt.close()\r\n\r\n\tfor x in ('Tools', 'extras'):\r\n\t\tos.chmod(join('waflib',x), 493)\r\n\r\n\tif sys.hexversion<0x300000f:\r\n\t\tsys.path = [join(dir, 'waflib')] + sys.path\r\n\t\timport fixpy2\r\n\t\tfixpy2.fixdir(dir)\r\n\r\n\tos.remove(tmp)\r\n\tos.chdir(cwd)\r\n\r\n\ttry: dir = unicode(dir, 'mbcs')\r\n\texcept: pass\r\n\ttry:\r\n\t\tfrom ctypes import windll\r\n\t\twindll.kernel32.SetFileAttributesW(dir, 2)\r\n\texcept:\r\n\t\tpass\r\n\r\ndef test(dir):\r\n\ttry:\r\n\t\tos.stat(join(dir, 'waflib'))\r\n\t\treturn os.path.abspath(dir)\r\n\texcept OSError:\r\n\t\tpass\r\n\r\ndef find_lib():\r\n\tsrc = os.path.abspath(inspect.getfile(inspect.getmodule(err)))\r\n\tbase, name = os.path.split(src)\r\n\r\n\t#devs use $WAFDIR\r\n\tw=test(os.environ.get('WAFDIR', ''))\r\n\tif w: return w\r\n\r\n\t#waf-light\r\n\tif name.endswith('waf-light'):\r\n\t\tw = test(base)\r\n\t\tif w: return w\r\n\t\terr('waf-light requires waflib -> export WAFDIR=/folder')\r\n\r\n\tdirname = '%s-%s-%s' % (WAF, VERSION, REVISION)\r\n\tfor i in (INSTALL,'/usr','/usr/local','/opt'):\r\n\t\tw = test(i + '/lib/' + dirname)\r\n\t\tif w: return w\r\n\r\n\t#waf-local\r\n\tdir = join(base, (sys.platform != 'win32' and '.' or '') + dirname)\r\n\tw = test(dir)\r\n\tif w: return w\r\n\r\n\t#unpack\r\n\tunpack_wafdir(dir, src)\r\n\treturn dir\r\n\r\nwafdir = find_lib()\r\nsys.path.insert(0, wafdir)\r\n\r\nif __name__ == '__main__':\r\n\r\n\tfrom waflib import Scripting\r\n\tScripting.waf_entry_point(cwd, VERSION, wafdir)\r\n\r\n# Very long mostly-binary comment redacted here\r\n\r\n'''\r\n\r\nproject = rope.base.project.Project(\r\n    \"/Users/erichanchrow/git-repositories/3rd-party/ntpsec/\",\r\n    ropefolder=None\r\n)\r\nresource = rope.base.libutils.path_to_resource(\r\n    project,\r\n    \"/Users/erichanchrow/git-repositories/3rd-party/ntpsec/waf\",\r\n    'file'\r\n)\r\nrope.contrib.codeassist.get_calltip(\r\n    project, source, 1459, resource, maxfixes=5, remove_self=True\r\n)\r\n```\r\n"}}