changeset: 102042:78e5efa3dd9e branch: 3.5 parent: 102040:6bb68eae63e8 user: Serhiy Storchaka date: Tue Jun 14 22:52:04 2016 +0300 files: Lib/turtle.py Misc/ACKS Misc/NEWS description: Issue #27238: Got rid of bare excepts in the turtle module. Original patch by Jelle Zijlstra. diff -r 6bb68eae63e8 -r 78e5efa3dd9e Lib/turtle.py --- a/Lib/turtle.py Tue Jun 14 09:27:44 2016 -0700 +++ b/Lib/turtle.py Tue Jun 14 22:52:04 2016 +0300 @@ -179,7 +179,7 @@ continue try: key, value = line.split("=") - except: + except ValueError: print("Bad line in config-file %s:\n%s" % (filename,line)) continue key = key.strip() @@ -192,7 +192,7 @@ value = float(value) else: value = int(value) - except: + except ValueError: pass # value need not be converted cfgdict[key] = value return cfgdict @@ -220,7 +220,7 @@ try: head, tail = split(__file__) cfg_file2 = join(head, default_cfg) - except: + except Exception: cfg_file2 = "" if isfile(cfg_file2): cfgdict2 = config_dict(cfg_file2) @@ -229,7 +229,7 @@ try: readconfig(_CFG) -except: +except Exception: print ("No configfile read, reason unknown") @@ -653,7 +653,7 @@ x, y = (self.cv.canvasx(event.x)/self.xscale, -self.cv.canvasy(event.y)/self.yscale) fun(x, y) - except: + except Exception: pass self.cv.tag_bind(item, "" % num, eventfun, add) @@ -1158,7 +1158,7 @@ raise TurtleGraphicsError("bad color string: %s" % str(color)) try: r, g, b = color - except: + except (TypeError, ValueError): raise TurtleGraphicsError("bad color arguments: %s" % str(color)) if self._colormode == 1.0: r, g, b = [round(255.0*x) for x in (r, g, b)] @@ -2702,7 +2702,7 @@ return args try: r, g, b = args - except: + except (TypeError, ValueError): raise TurtleGraphicsError("bad color arguments: %s" % str(args)) if self.screen._colormode == 1.0: r, g, b = [round(255.0*x) for x in (r, g, b)] @@ -3865,7 +3865,7 @@ try: # eval(key).im_func.__doc__ = docsdict[key] eval(key).__doc__ = docsdict[key] - except: + except Exception: print("Bad docstring-entry: %s" % key) _LANGUAGE = _CFG["language"] @@ -3875,7 +3875,7 @@ read_docstrings(_LANGUAGE) except ImportError: print("Cannot find docsdict for", _LANGUAGE) -except: +except Exception: print ("Unknown Error when trying to import %s-docstring-dictionary" % _LANGUAGE) diff -r 6bb68eae63e8 -r 78e5efa3dd9e Misc/ACKS --- a/Misc/ACKS Tue Jun 14 09:27:44 2016 -0700 +++ b/Misc/ACKS Tue Jun 14 22:52:04 2016 +0300 @@ -1655,6 +1655,7 @@ Cheng Zhang Kai Zhu Tarek Ziadé +Jelle Zijlstra Gennadiy Zlobin Doug Zongker Peter Åstrand diff -r 6bb68eae63e8 -r 78e5efa3dd9e Misc/NEWS --- a/Misc/NEWS Tue Jun 14 09:27:44 2016 -0700 +++ b/Misc/NEWS Tue Jun 14 22:52:04 2016 +0300 @@ -13,6 +13,9 @@ Library ------- +- Issue #27238: Got rid of bare excepts in the turtle module. Original patch + by Jelle Zijlstra. + - Issue #27122: When an exception is raised within the context being managed by a contextlib.ExitStack() and one of the exit stack generators catches and raises it in a chain, do not re-raise the original exception