/usr/local/lib/python3.9/site-packages/future/builtins/__pycache__
Edit: /usr/local/lib/python3.9/site-packages/future/builtins/__pycache__/newsuper.cpython-39.pyc (3043B)
a
^Eg @ sh d Z ddlmZ ddlZddlmZ ddlmZmZ e Z
e ZeedfddZ
d d
Zdd ZdgZdS )
ah
This module provides a newsuper() function in Python 2 that mimics the
behaviour of super() in Python 3. It is designed to be used as follows:
from __future__ import division, absolute_import, print_function
from future.builtins import super
And then, for example:
class VerboseList(list):
def append(self, item):
print('Adding an item')
super().append(item) # new simpler super() function
Importing this module on Python 3 has no effect.
This is based on (i.e. almost identical to) Ryan Kelly's magicsuper
module here:
https://github.com/rfk/magicsuper.git
Excerpts from Ryan's docstring:
"Of course, you can still explicitly pass in the arguments if you want
to do something strange. Sometimes you really do want that, e.g. to
skip over some classes in the method resolution order.
"How does it work? By inspecting the calling frame to determine the
function object being executed and the object on which it's being
called, and then walking the object's __mro__ chain to find out where
that function was defined. Yuck, but it seems to work..."
)absolute_importN)FunctionType)PY3PY26 c C s | t u rt|}z|j|jjd }W n ttfyF tdY n0 zt ||j} W n^ t
ttfy zt |j|j} W n2 t
y tdY n ty tdY n0 Y n0 |t urt
| |S t
| S )zLike builtin super(), but capable of magic.
This acts just like the builtin super() function, but if called
without any arguments it attempts to infer them at runtime.
r z'super() used in a function with no argsz$super() used with an old-style classzsuper() called outside a method) _SENTINELsys _getframef_localsf_codeco_varnames
IndexErrorKeyErrorRuntimeError
find_ownerAttributeError TypeError __class___builtin_super)typZtype_or_obj
framedepthf r B/usr/local/lib/python3.9/site-packages/future/builtins/newsuper.pynewsuper- s$
r c C s | j D ]}|j D ]}zLt|tsbt|tr6|j}qz
|j}W q ty^ | | |}Y q0 qW n tt
fy~ Y qY n0 |j|u r| S qqt
dS )z=Find the class that owns the currently-executing method.
N)__mro____dict__values
isinstancer propertyfget__func__r __get__r func_code)clscoder methr r r r O s
r c O s, t d}|jj}ttdd|| i |S )Nr )r )r r r co_namegetattrr )argskwdsr nmr r r supermk s
r- )__doc__
__future__r r typesr Zfuture.utilsr r superr objectr r r r- __all__r r r r
s !"