You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
This file is not auto-generated and requires explicit user action to be created (either via the configuration editing feature or by manually creating it). It seems you did before #497 was fixed.
bpython now exists with an error message with instructions for the user. However, I don't think its bpython's job to second guess the user's decision on the default encoding. With #497 fixed, bpython only every creates a config file purely consisting of ASCII characters. Everything else if up to the user.
I guess that makes sense. Thanks for the explanation.
Does the exception also contain the byte offset? That would make it much easier to find the offending character. If it's not trivial, leave it like that, it's already a great help to know that it's "my" file that was faulty.
Uh oh!
There was an error while loading. Please reload this page.
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: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: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 bytese2 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.
The text was updated successfully, but these errors were encountered: