[DRAFT] Catch only Exception, not BaseException

This commit is contained in:
Chris Hennes
2021-02-10 14:08:56 -06:00
committed by wwmayer
parent 8228d64ac4
commit fe7e45a7de
16 changed files with 26 additions and 26 deletions

View File

@@ -1743,7 +1743,7 @@ class DraftToolBar:
c = self.panel.form.findChild(QtGui.QCheckBox,"ContinueCmd")
if c:
c.toggle()
except:
except Exception:
pass
def isConstructionMode(self):

View File

@@ -120,7 +120,7 @@ def get_dxf(obj, direction=None):
try:
d = Drawing.projectToDXF(obj.Shape, direction)
except:
except Exception:
# TODO: trap only specific exception.
# Impossible to generate DXF from Shape? Which exception is throw?
_wrn("get_dxf: "

View File

@@ -75,7 +75,7 @@ def get_line_style(line_style, scale):
# scale dashes
style = ",".join([str(float(d)/scale) for d in style])
# print("lstyle ", style)
except:
except Exception:
# TODO: trap only specific exception; what is the problem?
# Bad string specification?
return "none"

View File

@@ -183,7 +183,7 @@ def get_text(plane, techdraw,
try:
_t = text[0].replace("&", "&amp;").replace("<", "&lt;")
svg += _t.replace(">", "&gt;")
except:
except Exception:
# TODO: trap only specific exception; what is the problem?
# Bad UTF8 string specification? This can be removed
# once the code is only used with Python 3.
@@ -200,7 +200,7 @@ def get_text(plane, techdraw,
try:
_t = text[i].replace("&", "&amp;").replace("<", "&lt;")
svg += _t.replace(">", "&gt;")
except:
except Exception:
# TODO: trap only specific exception; what is the problem?
# Bad UTF8 string specification? This can be removed
# once the code is only used with Python 3.

View File

@@ -201,10 +201,10 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
if hasattr(vobj, attr):
try:
getattr(vobj,attr).setValue(attrvalue)
except:
except Exception:
try:
setattr(vobj,attr,attrvalue)
except:
except Exception:
unitvalue = U.Quantity(attrvalue, U.Length).Value
setattr(vobj,attr,unitvalue)
else:

View File

@@ -669,7 +669,7 @@ class Edit(gui_base_original.Modifier):
self.current_editing_object_gui_tools = None
self.ghost.finalize()
self.ghost = None
except:
except Exception:
return
# -------------------------------------------------------------------------
@@ -914,7 +914,7 @@ class Edit(gui_base_original.Modifier):
except AttributeError:
try:
obj_gui_tools = self.gui_tools_repository.get(utils.get_type(obj))
except:
except Exception:
obj_gui_tools = None
return obj_gui_tools

View File

@@ -170,7 +170,7 @@ class ArchSpaceGuiTools(GuiTools):
editpoints = []
editpoints.append(obj.ViewObject.Proxy.getTextPosition(obj.ViewObject))
return editpoints
except:
except Exception:
pass
def update_object_from_edit_points(self, obj, node_idx, v, alt_edit_mode=0):

View File

@@ -132,7 +132,7 @@ class Draft_SetStyle_TaskPanel:
if dm in dmodes:
try:
vobj.DisplayMode = dm
except:
except Exception:
pass
if "ShapeColor" in vobj.PropertiesList:
vobj.ShapeColor = self.form.ShapeColor.property("color").rgb()<<8

View File

@@ -1018,7 +1018,7 @@ class Snapper:
if pt:
for p in pt:
snaps.append([p, 'intersection', self.toWP(p)])
except:
except Exception:
pass
# some curve types yield an error
# when trying to read their types

View File

@@ -1110,7 +1110,7 @@ class gridTracker(Tracker):
try:
import BimProject
hpts = BimProject.getHuman(loc)
except:
except Exception:
# BIM not installed
pass
else:

View File

@@ -80,7 +80,7 @@ def make_clone(obj, delta=None, forcedraft=False):
else:
try:
clonefunc = getattr(Arch,"make"+obj[0].Proxy.Type)
except:
except Exception:
pass # not a standard Arch object... Fall back to Draft mode
else:
cl = clonefunc()
@@ -96,7 +96,7 @@ def make_clone(obj, delta=None, forcedraft=False):
cl.Role = base.Role
cl.Description = base.Description
cl.Tag = base.Tag
except:
except Exception:
pass
if App.GuiUp:
gui_utils.format_object(cl,base)

View File

@@ -79,7 +79,7 @@ class Clone(DraftObject):
try:
sh = shapes[0].multiFuse(shapes[1:])
sh = sh.removeSplitter()
except:
except Exception:
pass
else:
return sh

View File

@@ -546,7 +546,7 @@ def calculate_placement(globalRotation,
try:
t = edge.tangentAt(get_parameter_from_v0(edge, offset))
t.normalize()
except:
except Exception:
_wrn(_tr("Cannot calculate path tangent. Copy not aligned."))
return placement
@@ -560,7 +560,7 @@ def calculate_placement(globalRotation,
try:
b = t.cross(n)
b.normalize()
except:
except Exception:
# weird special case, tangent and normal parallel
b = nullv
_wrn(_tr("Tangent and normal are parallel. Copy not aligned."))
@@ -585,7 +585,7 @@ def calculate_placement(globalRotation,
try:
b = t.cross(n)
b.normalize()
except:
except Exception:
b = nullv
_wrn(_tr("Cannot calculate path binormal. Copy not aligned."))
return placement

View File

@@ -150,7 +150,7 @@ class ShapeString(DraftObject):
# some fonts fail here
if face.Surface.Axis.z < 0.0:
face.reverse()
except:
except Exception:
pass
compFaces.append(face)
ret = Part.Compound(compFaces)

View File

@@ -113,7 +113,7 @@ def label_to_scale(label):
try :
scale = float(label)
return scale
except :
except Exception:
if ":" in label:
f = label.split(":")
elif "=" in label:
@@ -126,7 +126,7 @@ def label_to_scale(label):
den = App.Units.Quantity(f[1]).Value
scale = num/den
return scale
except:
except Exception:
err = QT_TRANSLATE_NOOP("draft",
"Unable to convert input into a "
"scale factor")

View File

@@ -184,7 +184,7 @@ def getDXFlibs():
import dxfColorMap
try:
import dxfReader
except:
except Exception:
libsok = False
except ImportError:
libsok = False
@@ -2045,10 +2045,10 @@ def addText(text, attrib=False):
# better store as utf8 always.
# try:
# val = val.decode("utf8").encode("Latin1")
# except:
# except Exception:
# try:
# val = val.encode("latin1")
# except:
# except Exception:
# pass
newob = Draft.makeText(val.split("\n"))
if hasattr(lay, "addObject"):
@@ -3537,7 +3537,7 @@ def getStr(l):
# dxf R12 files are rather over-sensitive with utf8...
try:
import unicodedata
except:
except Exception:
# fallback
return l.encode("ascii", errors="replace")
else: