관리-도구
편집 파일: _shims.cpython-311.pyc
� �܋f� � � � d Z ddlZddlZej d Z G d� de� � Z G d� de� � Ze� d� � Z e fd �Z e e _ [ dd �Zd� Z e dd� � Z e d e� � Z e 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 �<