Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1046 -- Made syndication feed framework not swallow TypeErrors…

… in functions. Thanks, junzhang.jn

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2341 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit bb8500449b8da7a11dbf8422f9b10d943281bb62 1 parent 25b149a
Adrian Holovaty authored February 18, 2006
1  AUTHORS
@@ -61,6 +61,7 @@ answer newbie questions, and generally made Django that much better:
61 61
     Robert Rock Howard <http://djangomojo.com/>
62 62
     Jason Huggins <http://www.jrandolph.com/blog/>
63 63
     Michael Josephson <http://www.sdjournal.com/>
  64
+    junzhang.jn@gmail.com
64 65
     Russell Keith-Magee <freakboy@iinet.net.au>
65 66
     Garth Kidd <http://www.deadlybloodyserious.com/>
66 67
     Sune Kirkeby <http://ibofobi.dk/>
12  django/contrib/syndication/feeds.py
@@ -33,9 +33,17 @@ def __get_dynamic_attr(self, attname, obj, default=None):
33 33
         except AttributeError:
34 34
             return default
35 35
         if callable(attr):
36  
-            try:
  36
+            # Check func_code.co_argcount rather than try/excepting the
  37
+            # function and catching the TypeError, because something inside
  38
+            # the function may raise the TypeError. This technique is more
  39
+            # accurate.
  40
+            if hasattr(attr, 'func_code'):
  41
+                argcount = attr.func_code.co_argcount
  42
+            else:
  43
+                argcount = attr.__call__.func_code.co_argcount
  44
+            if argcount == 2: # one argument is 'self'
37 45
                 return attr(obj)
38  
-            except TypeError:
  46
+            else:
39 47
                 return attr()
40 48
         return attr
41 49
 

0 notes on commit bb85004

Please sign in to comment.
Something went wrong with that request. Please try again.