File: _test_race_condition_helper.py

package info (click to toggle)
python-virtualenv 20.35.4%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,136 kB
  • sloc: python: 11,065; sh: 160; ansic: 61; csh: 47; makefile: 8
file content (42 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from __future__ import annotations

from typing import ClassVar


class _Finder:
    fullname = None
    lock: ClassVar[list] = []

    def find_spec(self, fullname, path, target=None):  # noqa: ARG002
        # This should handle the NameError gracefully
        try:
            distutils_patch = _DISTUTILS_PATCH
        except NameError:
            return
        if fullname in distutils_patch and self.fullname is None:
            return
        return

    @staticmethod
    def exec_module(old, module):
        old(module)
        try:
            distutils_patch = _DISTUTILS_PATCH
        except NameError:
            return
        if module.__name__ in distutils_patch:
            pass  # Would call patch_dist(module)

    @staticmethod
    def load_module(old, name):
        module = old(name)
        try:
            distutils_patch = _DISTUTILS_PATCH
        except NameError:
            return module
        if module.__name__ in distutils_patch:
            pass  # Would call patch_dist(module)
        return module


finder = _Finder()