�
�(�g�) � � � d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZddl m
Z
mZ e j dd�� Z
d� Zd� Zd� Zdd d
�d�Zd� Ze j dd
�� Ze j dd�� Zdddd�d�Z G d� de� Z G d� de� Zd� Zd� Ze j d� � Zd� Ze j dd�� Zy)� N� )�unlink�temp_dirc # � K � | r=t j � 5 t j ddt � d�� ddd� yd�� y# 1 sw Y yxY w�w)z�Context manager to suppress package and module deprecation
warnings when importing them.
If ignore is False, this context manager has no effect.
�ignorez.+ (module|package)N)�warnings�catch_warnings�filterwarnings�DeprecationWarning)r s �1/usr/lib/python3.12/test/support/import_helper.py�_ignore_deprecated_importsr
sN � �� � �
�
$�
$�
&� ��#�#�H�.C�$6�
8�� � �
� � �s �A� A�A�A�Ac �F � t j | = y # t $ r Y y w xY w�N)�sys�modules�KeyError)�names r �unloadr s% � �
��K�K�����
��
�s � � � c � � t | � t j D ]d }t j j || dz � }t |dz � dD ], }t t j j ||�� � �. �f y)z�'Forget' a module was ever imported.
This removes the module from sys.modules and deletes any PEP 3147/488 or
legacy .pyc files.
z.py�c)� r � )�optimizationN) r r �path�os�joinr � importlib�util�cache_from_source)�modname�dirname�source�opts r �forgetr$ % ss � � �7�O��8�8� O�������g�w���7�� �v��|��� O�C��9�>�>�3�3�F��3�M�N� O�O� c �. � t j j | � }t j j t j j
| � � }t j j || dz � }t j ||� |S )a Move a PEP 3147/488 pyc file to its legacy pyc location.
:param source: The file system path to the source file. The source file
does not need to exist, however the PEP 3147/488 pyc file must exist.
:return: The file system path to the legacy pyc file.
r )
r r r r r r! �abspathr �shutil�move)r" |