a ;jg@sdZgdZddlZddlZddlmZddlZz ddlZWne yVddlZYn0e Z e fZ e Ze ZeZddZddZd d Zd d ZdddZddZdZddZddZddZddZGdddZd ddZejZej 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. )bytesasbytes isfileobj getexceptionstrcharunicode asunicodeasbytes_nestedasunicode_nestedasstr open_latin1long basestringsixu integer_typesis_pathlib_pathnpy_load_modulePathpicklecontextlib_nullcontext os_fspath os_PathLikeN)rcCst|tr|dSt|SNlatin1 isinstancerdecodestrsr ;/usr/local/lib/python3.9/site-packages/numpy/compat/py3k.pyr"s  rcCst|tr|St|dSr)rrrencoderr r r!r's rcCst|tr|dSt|Srrrr r r!r ,s  r cCsBt|tjtjtjfsdSz|WdSty<YdS0dS)NFT)rioFileIOBufferedReaderBufferedWriterfilenoOSError)fr r r!r1s rrcCst||ddS)Nz iso-8859-1)modeencoding)open)filenamer+r r r!r <sr cCs|SNr rr r r!r?srUcCs tdS)N)sysexc_infor r r r!rDsrcCs2t|dr&t|ttfs&dd|DSt|SdS)N__iter__cSsg|] }t|qSr )r.0yr r r! Iz"asbytes_nested..)hasattrrrrrxr r r!rGsrcCs2t|dr&t|ttfs&dd|DSt|SdS)Nr4cSsg|] }t|qSr )r r5r r r!r8Or9z$asunicode_nested..)r:rrrrr;r r r!r Msr cCs t|tS)z Check whether obj is a `pathlib.Path` object. Prefer using ``isinstance(obj, os.PathLike)`` instead of this function. )rr)objr r r!rSsrc@s*eZdZdZd ddZddZddZdS) raContext 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__jszcontextlib_nullcontext.__init__cCs|jSr/r>)r@r r r! __enter__msz contextlib_nullcontext.__enter__cGsdSr/r )r@excinfor r r!__exit__pszcontextlib_nullcontext.__exit__)N)__name__ __module__ __qualname____doc__rArBrDr r r r!r\s rcCsddlm}|||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.machineryrI load_module)namefninforIr r r!rts r)r*)N)"rH__all__r2ospathlibrr#Zpickle5r ImportErrorintr rrr rrrrr rr rrrrr rrrfspathrPathLikerr r r r!s: