Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/dill/__pycache__/_shims.cpython-39.pyc
Ðазад
a h�h� � @ s� d Z ddlZddlZejd ZG dd� de�ZG dd� de�Ze�d�Z e fd d �Z e e _[ ddd�Zd d� Z e dd�Ze de�Ze de�ZdS )a6 Provides shims for compatibility between versions of dill and Python. Compatibility shims should be provided in this file. Here are two simple example use cases. Deprecation of constructor function: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Assume that we were transitioning _import_module in _dill.py to the builtin function importlib.import_module when present. @move_to(_dill) def _import_module(import_name): ... # code already in _dill.py _import_module = Getattr(importlib, 'import_module', Getattr(_dill, '_import_module', None)) The code will attempt to find import_module in the importlib module. If not present, it will use the _import_module function in _dill. Emulate new Python behavior in older Python versions: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CellType.cell_contents behaves differently in Python 3.6 and 3.7. It is read-only in Python 3.6 and writable and deletable in 3.7. if _dill.OLD37 and _dill.HAS_CTYPES and ...: @move_to(_dill) def _setattr(object, name, value): if type(object) is _dill.CellType and name == 'cell_contents': _PyCell_Set.argtypes = (ctypes.py_object, ctypes.py_object) _PyCell_Set(object, value) else: setattr(object, name, value) ... # more cases below _setattr = Getattr(_dill, '_setattr', setattr) _dill._setattr will be used when present to emulate Python 3.7 functionality in older versions of Python while defaulting to the standard setattr in 3.7+. See this PR for the discussion that lead to this system: https://github.com/uqfoundation/dill/pull/443 � Nz dill._dillc @ sF e Zd ZdZdgZdd� Zdd� Zdd� Zd d � Zdd� Z d d� Z dS )�Reducea� Reduce objects are wrappers used for compatibility enforcement during unpickle-time. They should only be used in calls to pickler.save and other Reduce objects. They are only evaluated within unpickler.load. Pickling a Reduce object makes the two implementations equivalent: pickler.save(Reduce(*reduction)) pickler.save_reduce(*reduction, obj=reduction) � reductionc O s0 |� dd�}|rt�t�}n t�t�}||_|S )a� Args: *reduction: a tuple that matches the format given here: https://docs.python.org/3/library/pickle.html#object.__reduce__ is_callable: a bool to indicate that the object created by unpickling `reduction` is callable. If true, the current Reduce is allowed to be used as the function in further save_reduce calls or Reduce objects. �is_callableF)�get�object�__new__�_CallableReducer r )�clsr �kwargsr �self� r �{/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/dill/_shims.pyr G s zReduce.__new__c C s d| j f S )NzReduce%s�r �r r r r �__repr__X s zReduce.__repr__c C s | S �Nr r r r r �__copy__Z s zReduce.__copy__c C s | S r r )r �memor r r �__deepcopy__\ s zReduce.__deepcopy__c C s | j S r r r r r r � __reduce__^ s zReduce.__reduce__c C s | � � S r �r )r �protocolr r r � __reduce_ex__` s zReduce.__reduce_ex__N)�__name__� __module__�__qualname__�__doc__� __slots__r r r r r r r r r r r : s r c @ s e Zd Zdd� ZdS )r c O s. | � � }|d }|d }||� }||i |��S )Nr � r )r �argsr r �funcZf_args�objr r r �__call__f s z_CallableReduce.__call__N)r r r r"