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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
U
O±d ã@sdZddddddddd    d
d d d dddddddddgZddlZddlZddlmZddlZz ddlZWne    k
r€ddlZYnXe
Z e
fZ e Ze ZeZdd„Zdd„Zdd
„Zdd„Zd(dd „Zd d„Zd!Zd"d„Zd#d„Zd$d    „Zd%d„ZGd&d„dƒZd)d'd„ZejZej Z!dS)*a³
Python 3.X compatibility tools.
 
While this file was originally intended for Python 2 -> 3 transition,
it is now used to create a compatibility layer between different
minor versions of Python 3.
 
While the active version of numpy may not support a given version of python, we
allow downstream libraries to continue to use these shims for forward
compatibility with numpy while they transition their code to newer versions of
Python.
ÚbytesÚasbytesÚ    isfileobjÚ getexceptionÚstrcharÚunicodeÚ    asunicodeÚasbytes_nestedÚasunicode_nestedÚasstrÚ open_latin1ÚlongÚ
basestringÚsixuÚ integer_typesÚis_pathlib_pathÚnpy_load_moduleÚPathÚpickleÚcontextlib_nullcontextÚ    os_fspathÚ os_PathLikeéN)rcCst|tƒr| d¡St|ƒS©NÚlatin1©Ú
isinstancerÚdecodeÚstr©Ús©r úHd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/compat/py3k.pyr"s
 
cCst|tƒr|St|ƒ d¡Sr)rrrÚencoderr r r!r's
cCst|tƒr| d¡St|ƒSrrrr r r!r
,s
 
cCst|tjtjtjfƒS©N)rÚioÚFileIOÚBufferedReaderÚBufferedWriter)Úfr r r!r1sÚrcCst||ddS)Nz
iso-8859-1)ÚmodeÚencoding)Úopen)Úfilenamer*r r r!r 4scCs|Sr#r rr r r!r7sÚUcCs t ¡dS)Né)ÚsysÚexc_infor r r r!r<scCs2t|dƒr&t|ttfƒs&dd„|DƒSt|ƒSdS)NÚ__iter__cSsg|] }t|ƒ‘qSr )r©Ú.0Úyr r r!Ú
<listcomp>Asz"asbytes_nested.<locals>.<listcomp>)Úhasattrrrrr©Úxr r r!r?scCs2t|dƒr&t|ttfƒs&dd„|DƒSt|ƒSdS)Nr2cSsg|] }t|ƒ‘qSr )r    r3r r r!r6Gsz$asunicode_nested.<locals>.<listcomp>)r7rrrrr8r r r!r    EscCs
t|tƒS)z„
    Check whether obj is a `pathlib.Path` object.
 
    Prefer using ``isinstance(obj, os.PathLike)`` instead of this function.
    )rr)Úobjr r r!rKsc@s*eZdZdZd    dd„Zdd„Zdd„ZdS)
ra­Context manager that does no additional processing.
 
    Used as a stand-in for a normal context manager, when a particular
    block of code is only sometimes used with a normal context manager:
 
    cm = optional_cm if condition else nullcontext()
    with cm:
        # Perform operation, using optional_cm if condition is True
 
    .. note::
        Prefer using `contextlib.nullcontext` instead of this context manager.
    NcCs
||_dSr#©Ú enter_result)Úselfr<r r r!Ú__init__bszcontextlib_nullcontext.__init__cCs|jSr#r;)r=r r r!Ú    __enter__esz contextlib_nullcontext.__enter__cGsdSr#r )r=Úexcinfor r r!Ú__exit__hszcontextlib_nullcontext.__exit__)N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r>r?rAr r r r!rTs
cCsddlm}|||ƒ ¡S)aÒ
    Load a module. Uses ``load_module`` which will be deprecated in python
    3.12. An alternative that uses ``exec_module`` is in
    numpy.distutils.misc_util.exec_mod_from_location
 
    .. versionadded:: 1.11.2
 
    Parameters
    ----------
    name : str
        Full module name.
    fn : str
        Path to module file.
    info : tuple, optional
        Only here for backward compatibility with Python 2.*.
 
    Returns
    -------
    mod : module
 
    r)ÚSourceFileLoader)Zimportlib.machineryrFÚ load_module)ÚnameÚfnÚinforFr r r!rls )r))N)"rEÚ__all__r0ÚosÚpathlibrr$Zpickle5rÚ ImportErrorÚintr rrr rrrrr
rr rrrrr    rrrÚfspathrÚPathLikerr r r r!Ú<module>s^
ü