o 6aC@sdZgdZddlZddlZddlmZddlZddlZddlmZ zddl Z Wn e y5ddl Z Ynwe Ze fZeZeZeZddZdd Zd d Zd d Zd ddZddZdZddZddZddZddZGdddZd!ddZ ej!Z"ej#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)r)ABCcCt|tr |dSt|SNlatin1 isinstancerdecodestrsr"3/usr/lib/python3/dist-packages/numpy/compat/py3k.pyr&  rcCst|tr|St|dSr)rrrencoder r"r"r#r+s rcCrrrr r"r"r#r 0r$r cCst|tjtjtjfSN)rioFileIOBufferedReaderBufferedWriter)fr"r"r#r5srrcCst||ddS)Nz iso-8859-1)modeencoding)open)filenamer-r"r"r#r 8sr cCs|Sr&r"r r"r"r#r;rUcCs tdS)N)sysexc_infor"r"r"r#r@s rcC.t|drt|ttfsdd|DSt|S)N__iter__cSg|]}t|qSr")r.0yr"r"r# Ez"asbytes_nested..)hasattrrrrrxr"r"r#rCrcCr6)Nr7cSr8r")r r9r"r"r#r<Kr=z$asunicode_nested..)r>rrrrr?r"r"r#r IrAr 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#rOs rc@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)selfrDr"r"r#__init__fs zcontextlib_nullcontext.__init__cCs|jSr&rC)rEr"r"r# __enter__isz contextlib_nullcontext.__enter__cGsdSr&r")rEexcinfor"r"r#__exit__lr1zcontextlib_nullcontext.__exit__r&)__name__ __module__ __qualname____doc__rFrGrIr"r"r"r#rXs   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)importlib.machineryrN load_module)namefninforNr"r"r#rps r)r,r&)%rM__all__r4ospathlibrr'abcrabc_ABCpickle5r ImportErrorintr rrr rrrrr rr rrrrr rrrfspathrPathLikerr"r"r"r#sB