view roundup/anypy/findargspec.py @ 7068:bc06bad26872

Remove dead code for handling LogoutAction. Dead code starts wih: ''' # I think now that LogoutAction redirects to # self.base ([tracker] web parameter in config.ini), # this code is not needed. However I am keeping it # around in case it has to come back to life. # Delete if this is still around in 3/2018. # rouilj 3/2017. # # Note using this code may cause a CSRF Login vulnerability. # Handle the case where user logs out and tries to # log in again in same window. # The csrf token for the login button is associated # with the prior login, so it will not validate.
author John Rouillard <rouilj@ieee.org>
date Wed, 23 Nov 2022 22:25:34 -0500
parents c588e64718fc
children
line wrap: on
line source

''' Wrapper for getargspec to support other callables and python 3 support

In python 3 just uses getfullargspec which handles regular functions
and classes with __call__ methods.
'''

try:
    # Python 3+
    from inspect import getfullargspec as getargspec
    findargspec = getargspec
except ImportError:
    # Python 2.5-2.7 modified from https://bugs.python.org/issue20828
    import inspect

    def findargspec(fn):
        if inspect.isfunction(fn) or inspect.ismethod(fn):
            inspectable = fn
        elif inspect.isclass(fn):
            inspectable = fn.__init__
        elif callable(fn):
            inspectable = fn.__call__
        else:
            inspectable = fn

        try:
            return inspect.getargspec(inspectable)
        except TypeError:
            raise

Roundup Issue Tracker: http://roundup-tracker.org/