File: //usr/local/lib/python3.9/site-packages/celery/utils/__pycache__/serialization.cpython-39.pyc
a
X>h � @ sd d Z ddlZddlZddlZddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZ ddlmZmZmZ zddlZW n ey� ddlZY n0 d ZeeefZd
d
d
ddddd
d�Zd
d� Zejejfdd�Zdd� Z d+dd�Z!dd� Z"G dd� de�Z#dd� Z$ejejfdd�Z%dd� Z&dd � Zd!d"� Zd,d#d$�Z'd%d&� Z(ej)e*fdddfd'd(�Z+d)d*� Z,dS )-z)Utilities for safely pickling exceptions.� N)� b64decode)� b64encode)�partial)�getmro)� takewhile)�bytes_to_str� safe_repr�str_to_bytes)�UnpickleableExceptionWrapper�subclass_exception�find_pickleable_exception�create_exception_cls�get_pickleable_exception�get_pickleable_etype�get_pickled_exception� strtoboolFT)�false�no�0�true�yes�1�on�offc C s t | |fd|i�S )zCreate new exception class.�
__module__)�type)�name�parent�module� r �D/usr/local/lib/python3.9/site-packages/celery/utils/serialization.pyr ! s r c C sV t | dg �}t| jt�D ]8}z||� }|||�� W n tyF Y q0 | S qdS )a� Find first pickleable exception base class.
With an exception instance, iterate over its super classes (by MRO)
and find the first super exception that's pickleable. It does
not go below :exc:`Exception` (i.e., it skips :exc:`Exception`,
:class:`BaseException` and :class:`object`). If that happens
you should use :exc:`UnpickleableException` instead.
Arguments:
exc (BaseException): An exception instance.
loads: decoder to use.
dumps: encoder to use
Returns:
Exception: Nearest pickleable parent exception class
(except :exc:`Exception` and parents), or if the exception is
pickleable it will return :const:`None`.
�argsN)�getattr�itermro� __class__�unwanted_base_classes� Exception)�exc�loads�dumps�exc_argsZsuperclsZsuperexcr r r r &