quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicolas Lehuen (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (MODPYTHON-13) Builtin functions not callable with mod_python.publisher.
Date Sat, 29 Jan 2005 13:01:17 GMT
     [ http://issues.apache.org/jira/browse/MODPYTHON-13?page=history ]
     
Nicolas Lehuen resolved MODPYTHON-13:
-------------------------------------

     Resolution: Fixed
    Fix Version: 3.1.4

Fixed and checked in.

> Builtin functions not callable with mod_python.publisher.
> ---------------------------------------------------------
>
>          Key: MODPYTHON-13
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-13
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.3
>     Reporter: Graham Dumpleton
>     Assignee: Nicolas Lehuen
>      Fix For: 3.1.4

>
> Create a handler file containing:
>   _dict = { "a": 1 }
>   keys = _dict.keys
> Where this file is called "builtin.py", access "builtin.py/keys".
> This yields the error:
>   Mod_python error: "PythonHandler mod_python.publisher"
>   Traceback (most recent call last):
>     File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/mod_python/apache.py",
line 308, in HandlerDispatch
>       result = object(req)
>     File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/mod_python/publisher.py",
line 136, in handler
>       result = util.apply_fs_data(object, req.form, req=req)
>     File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/mod_python/util.py",
line 356, in apply_fs_data
>       if not (fc.co_flags & 0x08):
>   UnboundLocalError: local variable 'fc' referenced before assignment
> To fix this, mod_python.util needs to be modified in apply_fs_data(). The
> modified section of code is:
>     fc = None
>     expected = [] 
>     if hasattr(object, "func_code"):
>         # function
>         fc = object.func_code
>         expected = fc.co_varnames[0:fc.co_argcount]
>     elif hasattr(object, 'im_func'):
>         # method
>         fc = object.im_func.func_code
>         expected = fc.co_varnames[1:fc.co_argcount]
>     elif type(object) is ClassType:
>         # class
>         fc = object.__init__.im_func.func_code
>         expected = fc.co_varnames[1:fc.co_argcount]
>     
>     # remove unexpected args unless co_flags & 0x08,
>     # meaning function accepts **kw syntax
>     if not fc:
>         args = {}
>     elif not (fc.co_flags & 0x08):
>         for name in args.keys():
>             if name not in expected:
>                 del args[name]
> Ie., give "fc" a default value, and if it is not able to be set in if clauses, wipe
> out "args" altogether.
> This change then correctly yields:
>   ['a']

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


Mime
View raw message