FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Issue #27238: Got rid of bare excepts in the turtle module. Original… · python/cpython@cefa917 · GitHub

Repository navigation

Commit cefa917

Browse files
Issue #27238: Got rid of bare excepts in the turtle module. Original patch
by Jelle Zijlstra.
1 parent fcbe337 commit cefa917

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

‎Lib/turtle.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def config_dict(filename):
179179
continue
180180
try:
181181
key, value = line.split("=")
182-
except:
182+
except ValueError:
183183
print("Bad line in config-file %s:\n%s" % (filename,line))
184184
continue
185185
key = key.strip()
@@ -192,7 +192,7 @@ def config_dict(filename):
192192
value = float(value)
193193
else:
194194
value = int(value)
195-
except:
195+
except ValueError:
196196
pass # value need not be converted
197197
cfgdict[key] = value
198198
return cfgdict
@@ -220,7 +220,7 @@ def readconfig(cfgdict):
220220
try:
221221
head, tail = split(__file__)
222222
cfg_file2 = join(head, default_cfg)
223-
except:
223+
except Exception:
224224
cfg_file2 = ""
225225
if isfile(cfg_file2):
226226
cfgdict2 = config_dict(cfg_file2)
@@ -229,7 +229,7 @@ def readconfig(cfgdict):
229229

230230
try:
231231
readconfig(_CFG)
232-
except:
232+
except Exception:
233233
print ("No configfile read, reason unknown")
234234

235235

@@ -653,7 +653,7 @@ def eventfun(event):
653653
x, y = (self.cv.canvasx(event.x)/self.xscale,
654654
-self.cv.canvasy(event.y)/self.yscale)
655655
fun(x, y)
656-
except:
656+
except Exception:
657657
pass
658658
self.cv.tag_bind(item, "<Button%s-Motion>" % num, eventfun, add)
659659

@@ -1158,7 +1158,7 @@ def _colorstr(self, color):
11581158
raise TurtleGraphicsError("bad color string: %s" % str(color))
11591159
try:
11601160
r, g, b = color
1161-
except:
1161+
except (TypeError, ValueError):
11621162
raise TurtleGraphicsError("bad color arguments: %s" % str(color))
11631163
if self._colormode == 1.0:
11641164
r, g, b = [round(255.0*x) for x in (r, g, b)]
@@ -2702,7 +2702,7 @@ def _cc(self, args):
27022702
return args
27032703
try:
27042704
r, g, b = args
2705-
except:
2705+
except (TypeError, ValueError):
27062706
raise TurtleGraphicsError("bad color arguments: %s" % str(args))
27072707
if self.screen._colormode == 1.0:
27082708
r, g, b = [round(255.0*x) for x in (r, g, b)]
@@ -3865,7 +3865,7 @@ def read_docstrings(lang):
38653865
try:
38663866
# eval(key).im_func.__doc__ = docsdict[key]
38673867
eval(key).__doc__ = docsdict[key]
3868-
except:
3868+
except Exception:
38693869
print("Bad docstring-entry: %s" % key)
38703870

38713871
_LANGUAGE = _CFG["language"]
@@ -3875,7 +3875,7 @@ def read_docstrings(lang):
38753875
read_docstrings(_LANGUAGE)
38763876
except ImportError:
38773877
print("Cannot find docsdict for", _LANGUAGE)
3878-
except:
3878+
except Exception:
38793879
print ("Unknown Error when trying to import %s-docstring-dictionary" %
38803880
_LANGUAGE)
38813881

‎Misc/ACKS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,7 @@ Uwe Zessin
16551655
Cheng Zhang
16561656
Kai Zhu
16571657
Tarek Ziadé
1658+
Jelle Zijlstra
16581659
Gennadiy Zlobin
16591660
Doug Zongker
16601661
Peter Åstrand

‎Misc/NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Core and Builtins
1313
Library
1414
-------
1515

16+
- Issue #27238: Got rid of bare excepts in the turtle module. Original patch
17+
by Jelle Zijlstra.
18+
1619
- Issue #27122: When an exception is raised within the context being managed
1720
by a contextlib.ExitStack() and one of the exit stack generators
1821
catches and raises it in a chain, do not re-raise the original exception

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL