]> granicus.if.org Git - python/commitdiff
Issue #27238: Got rid of bare excepts in the turtle module. Original patch
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 14 Jun 2016 19:52:13 +0000 (22:52 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 14 Jun 2016 19:52:13 +0000 (22:52 +0300)
by Jelle Zijlstra.

Lib/lib-tk/turtle.py
Misc/ACKS
Misc/NEWS

index 73a759075d94c4e4ad9aaccb34cf443a4aca0999..635f48d56c801b46fefc37f572f5a6e8f251ca91 100644 (file)
@@ -192,7 +192,7 @@ def config_dict(filename):
             continue
         try:
             key, value = line.split("=")
-        except:
+        except ValueError:
             print "Bad line in config-file %s:\n%s" % (filename,line)
             continue
         key = key.strip()
@@ -205,7 +205,7 @@ def config_dict(filename):
                     value = float(value)
                 else:
                     value = int(value)
-            except:
+            except ValueError:
                 pass # value need not be converted
         cfgdict[key] = value
     return cfgdict
@@ -234,7 +234,7 @@ def readconfig(cfgdict):
     try:
         head, tail = split(__file__)
         cfg_file2 = join(head, default_cfg)
-    except:
+    except BaseException:
         cfg_file2 = ""
     if isfile(cfg_file2):
         #print "2. Loading config-file %s:" % cfg_file2
@@ -249,7 +249,7 @@ def readconfig(cfgdict):
 
 try:
     readconfig(_CFG)
-except:
+except BaseException:
     print "No configfile read, reason unknown"
 
 
@@ -677,7 +677,7 @@ class TurtleScreenBase(object):
                     x, y = (self.cv.canvasx(event.x)/self.xscale,
                            -self.cv.canvasy(event.y)/self.yscale)
                     fun(x, y)
-                except:
+                except BaseException:
                     pass
             self.cv.tag_bind(item, "<Button%s-Motion>" % num, eventfun, add)
 
@@ -1105,7 +1105,7 @@ class TurtleScreen(TurtleScreenBase):
                 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)]
@@ -2606,7 +2606,7 @@ class RawTurtle(TPen, TNavigator):
             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)]
@@ -3755,7 +3755,7 @@ def read_docstrings(lang):
         #print key
         try:
             eval(key).im_func.__doc__ = docsdict[key]
-        except:
+        except BaseException:
             print "Bad docstring-entry: %s" % key
 
 _LANGUAGE = _CFG["language"]
@@ -3765,7 +3765,7 @@ try:
         read_docstrings(_LANGUAGE)
 except ImportError:
     print "Cannot find docsdict for", _LANGUAGE
-except:
+except BaseException:
     print ("Unknown Error when trying to import %s-docstring-dictionary" %
                                                                   _LANGUAGE)
 
index c6a4bc02f7ff12a34bd3578bee8cb40fba4b2224..5566f1f1f9caee29f466210ddec65f8973f32c7e 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1554,5 +1554,6 @@ Uwe Zessin
 Cheng Zhang
 Kai Zhu
 Tarek Ziadé
+Jelle Zijlstra
 Gennadiy Zlobin
 Peter Ã…strand
index 6e9f5c6ce5736580fde577af90974a996f36656d..0b3439fb84034096d269464cd2431c7b85a5a038 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,6 +13,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #27238: Got rid of bare excepts in the turtle module.  Original patch
+  by Jelle Zijlstra.
+
 - Issue #26386: Fixed ttk.TreeView selection operations with item id's
   containing spaces.