-
-
Notifications
You must be signed in to change notification settings - Fork 249
Description
Expected behavior: The command LC_ALL=C bpython3
opens a new bpython session.
Actual behavior: The command LC_ALL=C bpython3
croaks immediately, with this message:
Traceback (most recent call last):
File "/usr/bin/bpython3", line 11, in <module>
load_entry_point('bpython==0.17.1', 'console_scripts', 'bpython')()
File "/usr/lib/python3/dist-packages/bpython/curtsies.py", line 141, in main
help=_("start by pasting lines of a file into session")),
File "/usr/lib/python3/dist-packages/bpython/args.py", line 106, in parse
loadini(config, options.config)
File "/usr/lib/python3/dist-packages/bpython/config.py", line 140, in loadini
if not config.read(config_path):
File "/usr/lib/python3.6/configparser.py", line 697, in read
self._read(fp, filename)
File "/usr/lib/python3.6/configparser.py", line 1015, in _read
for lineno, line in enumerate(fp, start=1):
File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1597: ordinal not in range(128)
Sanity check: bpython3
(without any locale stuff) runs normally. LC_ALL=C bpython
runs normally, probably because python2 doesn't differentiate between string types (bytestring vs. ASCII string).
Meaning of the error message: It very likely refers to the file ~/.config.bpython/config
, which contains:
# The name of a helper executable that should perform pastebin upload on
# bpython’s behalf. If unset, bpython uploads pastes to bpaste.net. (default: )
#pastebin_helper = gist.py
I never touched bpython's config files, so the file must be autogenerated. Note the special character in bpython’s
, which starts at byte 1597 in my copy of the file. This is a unicode character, specifically it's the three bytes e2 80 99
. This is obviously not valid ASCII.
Manual workaround: use your favorite text editor to replace ’
by '
. This works for now.
Long-term workaround: The config parser should be changed to always assume UTF-8, if not indicated otherwise. Otherwise, it would be impossible for a user to specify paths and program names that contain non-ASCII characters. Also, it's a bit funny that the "parsing" of a comment can make bpython fail.