Opened 20 years ago
Closed 20 years ago
#1046 closed defect (fixed)
[patch]syndication_feeds's bug for TypeError
| Reported by: | Owned by: | Adrian Holovaty | |
|---|---|---|---|
| Component: | contrib.syndication | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
Description
at feeds.py's line 35:
if callable(attr):
    try:
        return attr(obj)
    except TypeError:
        return attr()
this code will hide TypeError that zhe 'attr(obj)' function throws.
so , i use below code to fix the little bug.
if callable(attr):
    if hasattr( attr , 'func_code' ):
        argcount = attr.func_code.co_argcount
    else:
        argcount = attr.__call__.func_code.co_argcount
    if argcount == 2:
        # one is self
        return attr(obj)
    else:
        return attr()
      
  Note:
 See   TracTickets
 for help on using tickets.
    
(In [2341]) Fixed #1046 -- Made syndication feed framework not swallow TypeErrors in functions. Thanks, junzhang.jn