Skip to content

Commit

Permalink
More robustification
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed Nov 17, 2023
1 parent a14a829 commit 459bf34
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion coconut/_pyparsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@

if CPYPARSING:
min_ver = min_versions["cPyparsing"] # inclusive
max_ver = get_next_version(min_versions["cPyparsing"], point_to_increment=len(max_versions["cPyparsing"]) - 1) # exclusive
max_ver = get_next_version(
min_versions["cPyparsing"],
point_to_increment=len(max_versions["cPyparsing"]) - 1,
) # exclusive
else:
min_ver = min_versions["pyparsing"] # inclusive
max_ver = get_next_version(min_versions["pyparsing"]) # exclusive
Expand Down
2 changes: 1 addition & 1 deletion coconut/compiler/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ def pickle_cache(original, cache_path, include_incremental=True, protocol=pickle
with univ_open(cache_path, "wb") as pickle_file:
pickle.dump(pickle_info_obj, pickle_file, protocol=protocol)
except Exception:
logger.log_exc()
logger.warn_exc()
return False
else:
return True
Expand Down
5 changes: 4 additions & 1 deletion coconut/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ def get_req_str(req):
max_ver = get_next_version(min_versions[req])
if None in max_ver:
assert all(v is None for v in max_ver), "invalid max version " + repr(max_ver)
max_ver = get_next_version(min_versions[req], point_to_increment=len(max_ver) - 1)
max_ver = get_next_version(
min_versions[req],
point_to_increment=len(max_ver) - 1,
)
req_str += ",<" + ver_tuple_to_str(max_ver)
return req_str

Expand Down
6 changes: 5 additions & 1 deletion coconut/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def warn_err(self, warning, force=False):
try:
raise warning
except Exception:
self.print_exc(warning=True)
self.warn_exc()

def log_warn(self, *args, **kwargs):
"""Log a warning."""
Expand All @@ -428,6 +428,10 @@ def print_exc(self, err=None, show_tb=None, warning=False):
"""Properly prints an exception."""
self.print_formatted_error(self.get_error(err, show_tb), warning)

def warn_exc(self, err=None):
"""Warn about the current or given exception."""
self.print_exc(err, warning=True)

def print_exception(self, err_type, err_value, err_tb):
"""Properly prints the given exception details."""
self.print_formatted_error(format_error(err_value, err_type, err_tb))
Expand Down

0 comments on commit 459bf34

Please sign in to comment.