Viewing File: /opt/hc_python/lib/python3.12/site-packages/importlib_metadata/__pycache__/_context.cpython-312.pyc
�
`�*jp
� �4 � d dl mZ d dlZd dlZ G d� d� Zy)� )�annotationsNc �t � e Zd ZdZdZeffd�Zd� Zed� � Z ed� � Z
ed� � Zd� Zd � Z
ed
�d�Zd� Zy
)�
ExceptionTrapa�
A context manager that will catch certain exceptions and provide an
indication they occurred.
>>> with ExceptionTrap() as trap:
... raise Exception()
>>> bool(trap)
True
>>> with ExceptionTrap() as trap:
... pass
>>> bool(trap)
False
>>> with ExceptionTrap(ValueError) as trap:
... raise ValueError("1 + 1 is not 3")
>>> bool(trap)
True
>>> trap.value
ValueError('1 + 1 is not 3')
>>> trap.tb
<traceback object at ...>
>>> with ExceptionTrap(ValueError) as trap:
... raise Exception()
Traceback (most recent call last):
...
Exception
>>> bool(trap)
False
)NNNc � � || _ y �N)�
exceptions)�selfr s �J/opt/hc_python/lib/python3.12/site-packages/importlib_metadata/_context.py�__init__zExceptionTrap.__init__, s � �$��� c � � | S r � �r s r
� __enter__zExceptionTrap.__enter__/ s � ��r c � � | j d S �Nr ��exc_infor s r
�typezExceptionTrap.type2 � � ��}�}�Q��r c � � | j d S )N� r r s r
�valuezExceptionTrap.value6 r r c � � | j d S )N� r r s r
�tbzExceptionTrap.tb: r r c �V � |d }|xr t || j � }|r|| _ |S r )�
issubclassr r )r r r �matchess r
�__exit__zExceptionTrap.__exit__>