[Checkins] SVN: zope.documenttemplate/trunk/ LP #267820: Fix broken multi-exception 'except:' clause.

Tres Seaver tseaver at palladion.com
Mon Oct 31 21:07:45 UTC 2011


Log message for revision 123201:
  LP #267820:  Fix broken multi-exception 'except:' clause.
  

Changed:
  U   zope.documenttemplate/trunk/CHANGES.txt
  U   zope.documenttemplate/trunk/src/zope/documenttemplate/dt_in.py

-=-
Modified: zope.documenttemplate/trunk/CHANGES.txt
===================================================================
--- zope.documenttemplate/trunk/CHANGES.txt	2011-10-31 21:04:29 UTC (rev 123200)
+++ zope.documenttemplate/trunk/CHANGES.txt	2011-10-31 21:07:45 UTC (rev 123201)
@@ -5,6 +5,8 @@
 3.4.3 (Unreleased)
 ------------------
 
+- LP #267820:  Fix broken multi-exception 'except:' clause.
+
 - Removed use of 'zope.testing.doctestunit' in favor of stdlib's doctest.
 
 - Simpler, faster implementation of dt_var.newline_to_br().

Modified: zope.documenttemplate/trunk/src/zope/documenttemplate/dt_in.py
===================================================================
--- zope.documenttemplate/trunk/src/zope/documenttemplate/dt_in.py	2011-10-31 21:04:29 UTC (rev 123200)
+++ zope.documenttemplate/trunk/src/zope/documenttemplate/dt_in.py	2011-10-31 21:07:45 UTC (rev 123201)
@@ -722,13 +722,10 @@
                 if multsort: # More than one sort key.
                     k = []
                     for sk in sortfields:
-                        try:
-                            if mapping:
-                                akey = v[sk]
-                            else:
-                                akey = getattr(v, sk)
-                        except AttributeError, KeyError:
-                            akey = None
+                        if mapping:
+                            akey = v.get(sk)
+                        else:
+                            akey = getattr(v, sk, None)
                         if not basic_type(akey):
                             try:
                                 akey = akey()
@@ -736,13 +733,10 @@
                                 pass
                         k.append(akey)
                 else: # One sort key.
-                    try:
-                        if mapping:
-                            k = v[sort]
-                        else:
-                            k = getattr(v, sort)
-                    except AttributeError, KeyError:
-                        k = None
+                    if mapping:
+                        k = v.get(sort)
+                    else:
+                        k = getattr(v, sort, None)
                     if not basic_type(type(k)):
                         try:
                             k = k()



More information about the checkins mailing list