AlkantarClanX12
Current Path : /opt/alt/python37/lib/python3.7/site-packages/future/builtins/__pycache__/ |
Current File : //opt/alt/python37/lib/python3.7/site-packages/future/builtins/__pycache__/newsuper.cpython-37.pyc |
B �A�[2 � @ s` d Z ddlmZ ddlZddlmZ ddlmZmZ e Z e� Zeedfdd�Z d d � 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)�PY3�PY26� c C sf | t k�rJt�|�}y|j|jjd }W n ttfk rJ td��Y nX y |j }W nB t tfk r� y|jj }W n t k r� td��Y nX Y nX x�|D ]�} x�| j� � D ]�}yVxPt|t��st|t�r�|j}q�y |j}W q� t k �r |�|| �}Y q�X q�W W n t tfk �r& w�Y nX |j|jkr�P q�W q�P q�W td��|t k �r^t| |�S t| �S )z�Like 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 a non-newstyle classzsuper() called outside a method)� _SENTINEL�sys� _getframe�f_locals�f_code�co_varnames� IndexError�KeyError�RuntimeError�__mro__�AttributeError� __class__�__dict__�values� isinstancer �property�fget�__func__�__get__� TypeError� func_code�_builtin_super)�typZtype_or_obj� framedepth�f�mro�meth� r"