summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-02-18 20:34:14 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-02-18 20:34:14 +0000
commitbb8500449b8da7a11dbf8422f9b10d943281bb62 (patch)
tree9254d048a88a59ea595751591827496b8299c08b /django
parent25b149a2a510df359f8fb485f32523d926b0150c (diff)
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
Diffstat (limited to 'django')
-rw-r--r--django/contrib/syndication/feeds.py12
1 files changed, 10 insertions, 2 deletions
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