Your IP : 18.117.151.198


Current Path : /opt/alt/python37/lib/python3.7/site-packages/future/builtins/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/future/builtins/__pycache__/newsuper.cpython-37.pyc

B

�A�[2�@s`dZddlmZddlZddlmZddlmZmZe	Z
e�Zeedfdd�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�cCsf|tk�rJt�|�}y|j|jjd}Wn ttfk
rJtd��YnXy
|j	}WnBt
tfk
r�y|jj	}Wnt
k
r�td��YnXYnXx�|D]�}x�|j�
�D]�}yVxPt|t��st|t�r�|j}q�y
|j}Wq�t
k
�r|�||�}Yq�Xq�WWnt
tfk
�r&w�YnX|j|jkr�Pq�Wq�Pq�Wtd��|tk	�r^t||�St|�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.
    rz'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"�I/opt/alt/python37/lib/python3.7/site-packages/future/builtins/newsuper.py�newsuper-sB







r$cOs(t�d�}|jj}ttdd�|�||�S)Nr�)r)rr	r�co_name�getattrr$)�args�kwdsr�nmr"r"r#�supermls
r+)�__doc__�
__future__rr�typesrZfuture.utilsrr�superr�objectrr$r+�__all__r"r"r"r#�<module> s?

?>