GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Exit gracefully if config file cannot be decoded (re #735) · pp1992m/bpython@d4a28ef

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • bpython
    • config.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bpython/config.py‎

Copy file name to clipboardExpand all lines: bpython/config.py
+13-7Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,19 @@ def loadini(struct, configfile):
137137
in iteritems(defaults['keyboard']))
138138

139139
fill_config_with_default_values(config, defaults)
140-
if not config.read(config_path):
141-
# No config file. If the user has it in the old place then complain
142-
if os.path.isfile(os.path.expanduser('~/.bpython.ini')):
143-
sys.stderr.write("Error: It seems that you have a config file at "
144-
"~/.bpython.ini. Please move your config file to "
145-
"%s\n" % default_config_path())
146-
sys.exit(1)
140+
try:
141+
if not config.read(config_path):
142+
# No config file. If the user has it in the old place then complain
143+
if os.path.isfile(os.path.expanduser('~/.bpython.ini')):
144+
sys.stderr.write("Error: It seems that you have a config file at "
145+
"~/.bpython.ini. Please move your config file to "
146+
"%s\n" % default_config_path())
147+
sys.exit(1)
148+
except UnicodeDecodeError as e:
149+
sys.stderr.write("Error: Unable to parse config file at '{}' due to an "
150+
"encoding issue. Please make sure to fix the encoding "
151+
"of the file or remove it and then try again.\n".format(config_path))
152+
sys.exit(1)
147153

148154
def get_key_no_doublebind(command):
149155
default_commands_to_keys = defaults['keyboard']

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.