관리-도구
편집 파일: newsuper.cpython-311.pyc
� �܋f � �r � d Z ddlmZ ddlZddlmZ ddlmZmZ e Z e� � Zeedfd�Z d� Zd � Zd gZdS )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 � � | t u r�t j |� � } |j |j j d }n$# t t f$ r t d� � �w xY w t ||j � � } nn# t t t f$ rT t |j |j � � } n5# t $ r t d� � �t $ r t d� � �w xY wY nw xY w|t urt | |� � 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 an old-style classzsuper() called outside a method)� _SENTINEL�sys� _getframe�f_locals�f_code�co_varnames� IndexError�KeyError�RuntimeError� find_owner�AttributeError� TypeError� __class__�_builtin_super)�typ�type_or_obj� framedepth�fs �i/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/future/builtins/newsuper.py�newsuperr - sN � � �i����M�*�%�%�� J��*�Q�X�%9�!�%<�=�K�K���H�&� J� J� J��H�I�I�I� J���� F��[�!�(�3�3�C�C����i�8� F� F� F� F� ��!6���A�A����!� K� K� K�"�#I�J�J�J�� F� F� F�"�#D�E�E�E� F���� �� F���� �)�#�#��c�;�/�/�/��#���s3 �= �!A�"A8 �8C#�B+�*C#�+2C�C#�"C#c � � | j D ]�}|j � � � D ]�} t |t � � sat |t � � r|j }n/ |j }n&# t $ r |� | |� � }Y nw xY wt |t � � �an# t t f$ r Y ��w xY w|j |u r|c c S ����t �)z=Find the class that owns the currently-executing method. )�__mro__�__dict__�values� isinstancer �property�fget�__func__r �__get__r � func_code)�cls�coder �meths r r r O s � � �{� � ���L�'�'�)�)� � �D� �$�T�,�7�7� :�!�$��1�1� :� $�y���:�#'�=�D�D��-� :� :� :�#'�<�<��S�#9�#9�D�D�D�:���� %�T�,�7�7� :��� #�I�.� � � ��� �����~��%�%�� � � � � � &�# �* �Os5 �2B�A!� B�! B�B�B�B�B1�0B1c � � t j d� � }|j j } t t d�� � |� � | i |��S )Nr � )r )r r r �co_name�getattrr )�args�kwdsr �nms r �supermr1 k sE � �� �a���A� �� �B�-�7�8�q�)�)�)�"�-�-�t�<�t�<�<�<� r )�__doc__� __future__r r �typesr �future.utilsr r �superr �objectr r r r1 �__all__� r2 r �<module>r; s� ��� �B '� &� &� &� &� &� � � � � � � � � � � "� "� "� "� "� "� "� "� ���F�H�H� �� �a� � � � �D� � �8=� =� =� �,���r2