summaryrefslogtreecommitdiff
path: root/numpy/compat/py3k.py
Commit message (Collapse)AuthorAgeFilesLines
* BUG: fix the method for checking local files (#23728)Hongyang Peng2023-05-091-1/+9
| | | | | | BufferedReader and BufferedWriter cannot be used to determine local files. For example, users can implement CustomFile to operate on OSS files, and then use BufferedReader(CustomFile) to achieve the buffered effect. But fileno method can do it.
* ENH: provide a convenience function to replace npy_load_module (#20395)Matti Picus2021-11-191-1/+3
| | | | | | | `load_module` is deprecated since python 3.4 and will be removed in python 3.12. Use `exec_module` instead. Provide a convenience function in `distutils.misc_utils` instead of `npy_load_module` from `compat.py3k`.
* MAINT: Remove unused imports and unreachable code (#18762)Elisha Hollander2021-07-071-4/+0
| | | * Remove unnecessary imports and minor fixes
* DOC: Add a note that one should preferably use `contextlib.nullcontext`Bas van Beek2020-12-051-0/+3
|
* MAINT: Cleanup compatibility code for pathlibEric Wieser2020-10-101-5/+4
| | | | `Path` can now never be none, and `PurePath` is not used and not in `__all__`.
* MAINT: py3k: remove os.fspath and os.PathLike backports (#17473)Wei Yang2020-10-101-51/+2
| | | | | Since we no longer support Python 3.5 and below, this code is unreachable. As with the rest of `py3k.py`, we leave behind the aliases to prevent breaking downstream code.
* Merge pull request #15011 from hmaarrfk/compat_cleanup_35Sebastian Berg2020-01-161-118/+51
|\ | | | | MAINT: cleanup compat.py3k.py
| * MAINT: cleanup compat.py3k.pyMark Harfouche2020-01-031-118/+51
| |
* | MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-051-1/+1
|/ | | | | | | Inheriting from object was necessary for Python 2 compatibility to use new-style classes. In Python 3, this is unnecessary as there are no old-style classes. Dropping the object is more idiomatic Python.
* Fix typos, via a Levenshtein-style correctorBrian Wignall2019-12-191-1/+1
|
* DOC: add a more useful comment to compat.py3k.pyMark Harfouche2019-11-291-3/+9
|
* DEV: cleanup imports and some assignments (from LGTM)mattip2019-03-171-2/+1
|
* MAINT: Move pickle import to numpy.compatCharles Harris2019-02-211-3/+8
| | | | | | | The pickle module was being imported from numpy.core.numeric. It was defined there in order to use pickle5 when available in Python3 and cpickle in Python2. The numpy.compat module seems a better place for that.
* ENH: Add support for third-party path-like objects by backporting os.fspathEric Wieser2018-10-121-3/+67
|
* MAINT: Close the file if any unexpected errors occur within memmapEric Wieser2018-09-231-1/+24
|
* BUG: import full module path in npy_load_moduleJonathan Helmus2016-10-121-1/+1
| | | | | | | | Use the full module path when importing importlib.machinery for use in the npy_load_module function. Just importing importlib is not sufficient in certain cases, for example Python 3.4. closes #8147
* MAINT,DOC: add to compat.py3k a function to load modules. Fix some doc for ↵bertrand2016-07-171-2/+59
| | | | f2py.compile (issue #7683)
* ENH: Add support for pathlib.Path objects to save/load functionsWendell Smith2016-04-061-1/+12
|
* STY: Minor PEP8 fixes.Charles Harris2014-08-011-1/+0
|
* FIX isfileobj accepts write-mode files under PY3Olivier Grisel2014-06-301-1/+1
|
* ENH: export py3k.integer_types from numpy.compatChristoph Gohlke2013-09-071-1/+2
|
* 2to3: Apply unicode fixer.Charles Harris2013-04-211-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | The unicode fixer strips the u from u'hi' and converts the unicode type to str. The first won't work for Python 2 and instead we replace the u prefix with the sixu function borrowed from the six compatibility package. That function calls the unicode constructor with the 'unicode_escape' encoder so that the many tests using escaped unicode characters like u'\u0900' will be handled correctly. That makes the sixu function a bit different from the asunicode function currently in numpy.compat and also provides a target that can be converted back to the u prefix when support for Python 3.2 is dropped. Python 3.3 reintroduced the u prefix for compatibility. The unicode fixer also replaces 'unicode' with 'str' as 'unicode' is no longer a builtin in Python 3. For code compatibility, 'unicode' is defined either as 'str' or 'unicode' in numpy.compat so that checks like if isinstance(x, unicode): ... will work properly for all python versions. Closes #3089.
* 2to3: Apply basestring fixer.Charles Harris2013-04-131-1/+4
| | | | | | | | | | | The basestring class is not defined in Python 3 and the fixer replaces it with str. In order to have a common code base we define basestring in numpy/compat/py3k.py to be str when the Python version is >= 3, otherwise basestring and import it where needed. That works for most cases, but there are a few files where the version dependent define needs to be in the file. Closes #3042.
* 2to3: Apply the `numliterals` fixer and skip the `long` fixer.Charles Harris2013-04-131-1/+8
| | | | | | | | | | | | | | | | | | | The numliterals fixer replaces the old style octal number like '01' by '0o1' removes the 'L' suffix. Octal values were previously mistakenly specified in some dates, those uses have been corrected by removing the leading zeros. Simply Removing the 'L' suffix should not be a problem, but in some testing code it looks neccesary, so in those places the Python long constructor is used instead. The 'long' type is no longer defined in Python 3. Because we need to have it defined for Python 2 it is added to numpy/compat/np3k.py where it is defined as 'int' for Python 3 and 'long' for Python 2. The `long` fixer then needs to be skipped so that it doesn't undo the good work. Closes #3074, #3067.
* 2to3: Apply `print` fixer.Charles Harris2013-04-061-1/+1
| | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* 2to3: Use absolute imports.Charles Harris2013-03-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new import `absolute_import` is added the `from __future__ import` statement and The 2to3 `import` fixer is run to make the imports compatible. There are several things that need to be dealt with to make this work. 1) Files meant to be run as scripts run in a different environment than files imported as part of a package, and so changes to those files need to be skipped. The affected script files are: * all setup.py files * numpy/core/code_generators/generate_umath.py * numpy/core/code_generators/generate_numpy_api.py * numpy/core/code_generators/generate_ufunc_api.py 2) Some imported modules are not available as they are created during the build process and consequently 2to3 is unable to handle them correctly. Files that import those modules need a bit of extra work. The affected files are: * core/__init__.py, * core/numeric.py, * core/_internal.py, * core/arrayprint.py, * core/fromnumeric.py, * numpy/__init__.py, * lib/npyio.py, * lib/function_base.py, * fft/fftpack.py, * random/__init__.py Closes #3172
* 2to3: Put `from __future__ import division in every python file.Charles Harris2013-03-011-0/+1
| | | | | | | | This should be harmless, as we already are division clean. However, placement of this import takes some care. In the future a script can be used to append new features without worry, at least until such time as it exceeds a single line. Having that ability will make it easier to deal with absolute imports and printing updates.
* BUG: Fix ticket #1990.Bryan Van de Ven2012-03-031-6/+19
| | | | | | | When an array is created from a sequence of numeric (boolean, int, float, complex) and string (bytes, str, unicode) values, the resulting array type is string, but only the string values were being used to choose the string length, leading to truncation of data.
* BUG:py3k: fix error with recarry. Patch by C. Gohlke. Closes #1843.Ralf Gommers2011-07-011-1/+1
|
* BUG: compat: fix a bug in open_latin1Pauli Virtanen2010-05-131-1/+1
|
* BUG/3K: distutils: do not assume that files output e.g. by gcc can be read ↵Pauli Virtanen2010-05-111-1/+5
| | | | in ascii codec
* 3K: lib: more str vs bytes issues in the lib/io loadtxt, savetxt and genfromtxtPauli Virtanen2010-02-201-1/+1
|
* ENH: compat: additional Py3 convenience functionsPauli Virtanen2010-02-201-3/+9
|
* 3K: compat: make isfileobj recognize only real file objects with FILE* ↵Pauli Virtanen2010-02-201-1/+1
| | | | pointers as file objects
* ENH: Add some tools to numpy.compatPauli Virtanen2010-02-201-2/+15
|
* 3K: core: adjust some tests vs. str/bytes and int inheritance issuesPauli Virtanen2010-02-201-1/+7
|
* 3K: BUG: core: fix some tests for Py3Pauli Virtanen2010-02-201-1/+3
|
* 3K: compat: add getexception to compat.py3kPauli Virtanen2009-12-061-1/+6
|
* 3K: rename compat.isfile to isfileobj to avoid confusion with os.pathPauli Virtanen2009-12-061-3/+3
|
* 3K: add some compatibility tools to numpy.compatPauli Virtanen2009-12-061-0/+22