summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--django/contrib/syndication/feeds.py12
2 files changed, 11 insertions, 2 deletions
diff --git a/AUTHORS b/AUTHORS
index 61558a3900..1e5209319b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -61,6 +61,7 @@ answer newbie questions, and generally made Django that much better:
Robert Rock Howard <http://djangomojo.com/>
Jason Huggins <http://www.jrandolph.com/blog/>
Michael Josephson <http://www.sdjournal.com/>
+ junzhang.jn@gmail.com
Russell Keith-Magee <freakboy@iinet.net.au>
Garth Kidd <http://www.deadlybloodyserious.com/>
Sune Kirkeby <http://ibofobi.dk/>
diff --git a/django/contrib/syndication/feeds.py b/django/contrib/syndication/feeds.py
index 49b34858dc..8e3ccdb6c3 100644
--- a/django/contrib/syndication/feeds.py
+++ b/django/contrib/syndication/feeds.py
@@ -33,9 +33,17 @@ class Feed:
except AttributeError:
return default
if callable(attr):
- try:
+ # Check func_code.co_argcount rather than try/excepting the
+ # function and catching the TypeError, because something inside
+ # the function may raise the TypeError. This technique is more
+ # accurate.
+ if hasattr(attr, 'func_code'):
+ argcount = attr.func_code.co_argcount
+ else:
+ argcount = attr.__call__.func_code.co_argcount
+ if argcount == 2: # one argument is 'self'
return attr(obj)
- except TypeError:
+ else:
return attr()
return attr