- suppresses the warning about over.type

- makes sure traceback handler doesn't cause a crash itself
This commit is contained in:
Martinez 2017-02-16 12:50:07 +01:00
parent d0bac63fb3
commit 2dfa580c75
4 changed files with 67 additions and 70 deletions

View file

@ -19,6 +19,6 @@ print = text.Output("over.__init__", stream=sys.stderr)
core = aux.DeprecationForwarder(sys.modules[__name__], "over.core", "over")
textui = aux.DeprecationForwarder(text, "over.core.textui", "over.text")
for module in [types]:
if module.__file__[-2:] == "py":
print("<r>unable to load C implementation<.> of <c>%s<.>, falling back to pure Python instead" %(module.__name__), print.tl.warn)
#for module in [types]:
# if module.__file__[-2:] == "py":
# print("<r>unable to load C implementation<.> of <y>%s<.>, falling back to pure Python instead" %(module.__name__), print.tl.warn)

View file

@ -10,6 +10,7 @@ import re
import os
import shlex
import hashlib
import traceback
try:
import xdg.BaseDirectory as xdg_bd
@ -134,11 +135,7 @@ class Option:
if default:
if self.default != Option_sources.none:
# default values for aggregated options are wrapped in a list
default_values = [self.default] if self.overwrite else self.default
for default_value in default_values:
self.set_value(default_value, Option_sources.default)
self.set_value(self.default, Option_sources.default)
def set_value(self, raw_value, source):
"""
@ -728,13 +725,13 @@ class Main:
@while formatting a traceback
Over Exception handler - prints human readable tracebacks.
If things go south even here, prints the topmost traceback and gives up in a safe manner.
"""
self.print("<R>uncontained exception<.> <Y>%s<.> raised" %(exception_type.__name__), self.print.tl.fail)
# todo top level program name
# todo final level exception name and text
try:
tb_lines = ["", "---------------- Stack trace ----------------", "In program <W>%s<.>" %(self.invocation)]
while trace:
@ -745,29 +742,24 @@ class Main:
# if there's a "self" in locals, we can get a hold of the method using getattr
if "self" in frame.f_locals:
method = getattr(frame.f_locals["self"], method_name)
method_display_name = " <c>%s<.>.<y>%s<.>" %(method.__self__.__class__.__name__, method_name)
method_display_name = "<c>%s<.>.<y>%s<.>" %(method.__self__.__class__.__name__, method_name)
method_type = "method"
# if it's a global function, it's likely going to be here
elif method_name in frame.f_globals:
method = frame.f_globals[method_name]
method_display_name = " <y>%s<.>" %(method_name)
method_display_name = "<y>%s<.>" %(method_name)
method_type = "function"
# otherwise give up
else:
method = None
method_display_name = ""
method_display_name = "<y>%s<.>" %(method_name)
if method_name == "<module>":
method_type = "module"
elif method_name == "<listcomp>":
method_type = "a list comprehension"
elif method_name == "<genexpr>":
method_type = "a generator expression"
else:
method_type = "<r>unknown callable<.>"
method_display_name = " <y>%s<.>" %(method_name)
# use a docstring-provided action description if available
if method and method.__doc__ and "@while" in method.__doc__:
@ -775,7 +767,7 @@ class Main:
else:
action = ""
tb_lines.append("%sin %s%s at %s:%d," %(action, method_type, method_display_name, frame.f_code.co_filename, frame.f_lineno))
tb_lines.append("%sin %s <y>%s<.> at %s:%d," %(action, method_type, method_display_name, frame.f_code.co_filename, frame.f_lineno))
if hasattr(exception, "description"):
reason = ": <R>%s<.>" %(exception.description)
@ -800,3 +792,7 @@ class Main:
self.print(line, format=format, end="\n")
self.print("---------------------------------------------", format="<t>", end="\n")
except:
self.print("<R>failed to contain exception<.>", self.print.tl.epic)
traceback.print_exc()

View file

@ -302,6 +302,7 @@ class Output:
note = "<C>NOTE<.>"
warn = "<Y>WARN<.>"
fail = "<R>FAIL<.>"
epic = "<R>EPIC<.>"
done = "<G>DONE<.>"
ts = tag.short

View file

@ -4,5 +4,5 @@
major = 1 # VERSION_MAJOR_IDENTIFIER
minor = 99 # VERSION_MINOR_IDENTIFIER
# VERSION_LAST_MM 1.99
patch = 9 # VERSION_PATCH_IDENTIFIER
str = ".".join(str(v) for v in (major, minor, patch))
patch = 18 # VERSION_PATCH_IDENTIFIER
str = "1.99.18" # VERSION_STRING_IDENTIFIER