summaryrefslogtreecommitdiff
path: root/Python/fileutils.c
AgeCommit message (Collapse)AuthorLines
2018-11-20bpo-28604: Fix localeconv() for different LC_MONETARY (GH-10606) (GH-10619) ↵Victor Stinner-2/+2
(GH-10621) locale.localeconv() now sets temporarily the LC_CTYPE locale to the LC_MONETARY locale if the two locales are different and monetary strings are non-ASCII. This temporary change affects other threads. Changes: * locale.localeconv() can now set LC_CTYPE to LC_MONETARY to decode monetary fields. * Add LocaleInfo.grouping_buffer: copy localeconv() grouping string since it can be replaced anytime if a different thread calls localeconv(). (cherry picked from commit 02e6bf7f2025cddcbde6432f6b6396198ab313f4) (cherry picked from commit 6eff6b8eecd7a8eccad16419269fa18ec820922e)
2018-10-18[3.6] bpo-24658: Fix read/write greater than 2 GiB on macOS (GH-1705) (GH-9937)Stéphane Wirtel-19/+5
On macOS, fix reading from and writing into a file with a size larger than 2 GiB. (cherry picked from commit 74a8b6ea7e0a8508b13a1c75ec9b91febd8b5557)
2018-08-28bpo-34527: Fix FreeBSD with POSIX locale (GH-8975)Victor Stinner-1/+1
On FreeBSD, Py_DecodeLocale() and Py_EncodeLocale() now also forces the ASCII encoding if the LC_CTYPE locale is "POSIX", not only if the LC_CTYPE locale is "C".
2018-02-18bpo-32869: Fix incorrect dst buffer size for MultiByteToWideChar (GH-5739)Miss Islington (bot)-1/+2
This function expects the destination buffer size to be given in wide characters, not bytes. (cherry picked from commit b3b4a9d3001f1fc7df8efcccdce081de54fa5eab) Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
2018-02-05bpo-32777: Fix _Py_set_inheritable async-safety in subprocess (GH-5560) ↵Miss Islington (bot)-3/+16
(GH-5563) Fix a rare but potential pre-exec child process deadlock in subprocess on POSIX systems when marking file descriptors inheritable on exec in the child process. This bug appears to have been introduced in 3.4 with the inheritable file descriptors support. This also changes Python/fileutils.c `set_inheritable` to use the "slow" two `fcntl` syscall path instead of the "fast" single `ioctl` syscall path when asked to be async signal safe (by way of being asked not to raise exceptions). `ioctl` is not a POSIX async-signal-safe approved function. ref: http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html (cherry picked from commit c1e46e94de38a92f98736af9a42d89c3975a9919) Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
2018-01-15[3.6] bpo-32555: Fix locale encodings (#5193)Victor Stinner-94/+157
On FreeBSD and Solaris, os.strerror() now always decode the byte string from the current locale encoding, rather than using ASCII/surrogateescape in some cases. Changes: * Add _Py_DecodeLocaleEx() and _Py_EncodeLocaleEx() which has an additional current_locale parameter. * PyUnicode_DecodeLocale(), PyUnicode_DecodeLocaleAndSize() and * PyUnicode_EncodeLocale() now always use the current locale * encoding, instead of using Py_DecodeLocale()/Py_EncodeLocale(). * Document encoding in Py_DecodeLocale() and Py_EncodeLocale() documentations. * Add USE_FORCE_ASCII define to not define decode_ascii_surrogateescape() on Android.
2018-01-15[3.6] bpo-31900: Fix localeconv() encoding for LC_NUMERIC (#4174) (#5192)Victor Stinner-0/+77
* Add _Py_GetLocaleconvNumeric() function: decode decimal_point and thousands_sep fields of localeconv() from the LC_NUMERIC encoding, rather than decoding from the LC_CTYPE encoding. * Modify locale.localeconv() and "n" formatter of str.format() (for int, float and complex to use _Py_GetLocaleconvNumeric() internally. (cherry picked from commit cb064fc2321ce8673fe365e9ef60445a27657f54)
2017-06-28[3.6] bpo-13617: Reject embedded null characters in wchar* strings. ↵Serhiy Storchaka-6/+17
(GH-2302) (#2462) Based on patch by Victor Stinner. Add private C API function _PyUnicode_AsUnicode() which is similar to PyUnicode_AsUnicode(), but checks for null characters.. (cherry picked from commit f7eae0adfcd4c50034281b2c69f461b43b68db84)
2017-03-09bpo-29619: Convert st_ino using unsigned integer (#557) (#584)Victor Stinner-2/+2
bpo-29619: os.stat() and os.DirEntry.inodeo() now convert inode (st_ino) using unsigned integers. (cherry picked from commit 0f6d73343d342c106cda2219ebb8a6f0c4bd9b3c) (Misc/NEWS conflict handled manually.)
2016-12-15Issue #26919: On Android, operating system data is now always encoded/decodedXavier de Gaye-5/+5
to/from UTF-8, instead of the locale encoding to avoid inconsistencies with os.fsencode() and os.fsdecode() which are already using UTF-8.
2016-11-19Issue #28746: Fix the set_inheritable() file descriptor method on platformsXavier de Gaye-1/+1
that do not have the ioctl FIOCLEX and FIONCLEX commands
2016-09-09Fix check_force_ascii()Victor Stinner-8/+9
Issue #27938: Normalize aliases of the ASCII encoding, because _Py_normalize_encoding() now correctly normalize encoding names.
2016-09-08Issue #23524: Finish removing _PyVerify_fd from sourcesSteve Dower-124/+4
2016-05-26Issue #27076: Merge spelling from 3.5Martin Panter-1/+1
2016-05-26Issue #27076: Doc, comment and tests spelling fixesMartin Panter-1/+1
Most fixes to Doc/ and Lib/ directories by Ville Skyttä.
2016-05-19Merge 3.5 (issue #27057)Victor Stinner-2/+7
2016-05-19Fix os.set_inheritable() on AndroidVictor Stinner-2/+7
Issue #27057: Fix os.set_inheritable() on Android, ioctl() is blocked by SELinux and fails with EACCESS. The function now falls back to fcntl(). Patch written by Michał Bednarski.
2016-04-17Avoid fcntl() if possible in set_inheritable()Victor Stinner-5/+13
Issue #26770: set_inheritable() avoids calling fcntl() twice if the FD_CLOEXEC is already set/cleared. This change only impacts platforms using the fcntl() implementation of set_inheritable() (not Linux nor Windows).
2016-03-14Add more checks on the GILVictor Stinner-0/+16
Issue #10915, #15751, #26558: * PyGILState_Check() now returns 1 (success) before the creation of the GIL and after the destruction of the GIL. It allows to use the function early in Python initialization and late in Python finalization. * Add a flag to disable PyGILState_Check(). Disable PyGILState_Check() when Py_NewInterpreter() is called * Add assert(PyGILState_Check()) to: _Py_dup(), _Py_fstat(), _Py_read() and _Py_write()
2015-12-17Fix a couple of typos in code commentsMartin Panter-2/+2
2015-10-11Close #24784: Fix compilation without thread supportVictor Stinner-0/+6
Add "#ifdef WITH_THREAD" around cals to: * PyGILState_Check() * _PyImport_AcquireLock() * _PyImport_ReleaseLock()
2015-04-12Issue #23524: Replace _PyVerify_fd function with calls to ↵Steve Dower-39/+56
_set_thread_local_invalid_parameter_handler.
2015-04-01Issue #23836: Document functions releasing the GIL in fileutils.cVictor Stinner-3/+5
2015-04-01Issue #23836: Add _Py_write_noraise() functionVictor Stinner-48/+83
Helper to write() which retries write() if it is interrupted by a signal (fails with EINTR).
2015-03-30Issue #23752: _Py_fstat() is now responsible to raise the Python exceptionVictor Stinner-11/+47
Add _Py_fstat_noraise() function when a Python exception is not welcome.
2015-03-24Issue #23753: Move _Py_wstat() from Python/fileutils.c to Modules/getpath.cVictor Stinner-17/+0
I expected more users of _Py_wstat(), but in practice it's only used by Modules/getpath.c. Move the function because it's not needed on Windows. Windows uses PC/getpathp.c which uses the Win32 API (ex: GetFileAttributesW()) not the POSIX API.
2015-03-24Issue #23753: Python doesn't support anymore platforms without stat() orVictor Stinner-16/+0
fstat(), these functions are always required. Remove HAVE_STAT and HAVE_FSTAT defines, and stop supporting DONT_HAVE_STAT and DONT_HAVE_FSTAT.
2015-03-20Issue #23708: Save/restore errno in _Py_read() and _Py_write()Victor Stinner-15/+21
Save and then restore errno because PyErr_CheckSignals() and PyErr_SetFromErrno() can modify it.
2015-03-20Issue #23708: Split assertion expression in two assertions in _Py_read() andVictor Stinner-2/+4
_Py_write() to know which test failed on the buildbot "AMD64 Snow Leop 3.x".
2015-03-19Issue #23708: Fix _Py_read() compilation error on WindowsVictor Stinner-1/+1
Fix typo: self->fd => fd
2015-03-19Issue #23708: Add _Py_read() and _Py_write() functions to factorize code handleVictor Stinner-0/+149
EINTR error and special cases for Windows. These functions now truncate the length to PY_SSIZE_T_MAX to have a portable and reliable behaviour. For example, read() result is undefined if counter is greater than PY_SSIZE_T_MAX on Linux.
2015-03-18Issue #23694: Handle EINTR in _Py_open() and _Py_fopen_obj()Victor Stinner-13/+40
Retry open()/fopen() if it fails with EINTR and the Python signal handler doesn't raise an exception.
2015-03-18Issue #23694: Enhance _Py_fopen(), it now raises an exception on errorVictor Stinner-12/+36
* If fopen() fails, OSError is raised with the original filename object. * The GIL is now released while calling fopen()
2015-03-18Issue #23694: Enhance _Py_open(), it now raises exceptionsVictor Stinner-17/+55
* _Py_open() now raises exceptions on error. If open() fails, it raises an OSError with the filename. * _Py_open() now releases the GIL while calling open() * Add _Py_open_noraise() when _Py_open() cannot be used because the GIL is not held
2015-03-14Fixes incorrect use of GetLastError where errno should be used.Steve Dower-6/+6
2015-03-14Fixes incorrect use of GetLastError where errno should be used.Steve Dower-6/+6
2015-03-07Issue #23524: Change back to using Windows errors for _Py_fstat instead of ↵Steve Dower-3/+5
the errno shim.
2015-03-06Issue #23524: Replace _PyVerify_fd function with calling ↵Steve Dower-5/+103
_set_thread_local_invalid_parameter_handler on every thread.
2015-02-21Issue #23152: Renames time_t_to_FILE_TIME to _Py_time_t_to_FILE_TIME, ↵Steve Dower-4/+2
removes unused struct win32_stat and return value
2015-02-21Issue #23152: Renames attribute_data_to_stat to _Py_attribute_data_to_statSteve Dower-2/+2
2015-02-21Issue #23152: Implement _Py_fstat() to support files larger than 2 GB on ↵Steve Dower-2/+140
Windows. fstat() may fail with EOVERFLOW on files larger than 2 GB because the file size type is an signed 32-bit integer.
2015-01-04merge 3.4 (#23165)Benjamin Peterson-3/+13
2015-01-04merge 3.3 (closes #23165)Benjamin Peterson-3/+13
2015-01-04merge 3.2 (closes #23165)Benjamin Peterson-3/+13
2015-01-04add some overflow checks before multiplying (closes #23165)Benjamin Peterson-3/+13
2014-09-02Closes #22258: Fix the the internal function set_inheritable() on Illumos.Victor Stinner-14/+34
This platform exposes the function ioctl(FIOCLEX), but calling it fails with errno is ENOTTY: "Inappropriate ioctl for device". set_inheritable() now falls back to the slower fcntl() (F_GETFD and then F_SETFD).
2014-09-02(Merge 3.4) Closes #22258: Fix the the internal function set_inheritable() onVictor Stinner-14/+34
Illumos. This platform exposes the function ioctl(FIOCLEX), but calling it fails with errno is ENOTTY: "Inappropriate ioctl for device". set_inheritable() now falls back to the slower fcntl() (F_GETFD and then F_SETFD).
2014-08-01Issue #18395: Rename ``_Py_char2wchar()`` to :c:func:`Py_DecodeLocale`, renameVictor Stinner-32/+35
``_Py_wchar2char()`` to :c:func:`Py_EncodeLocale`, and document these functions.
2014-07-29Issue #22054: Add os.get_blocking() and os.set_blocking() functions to get andVictor Stinner-0/+53
set the blocking mode of a file descriptor (False if the O_NONBLOCK flag is set, True otherwise). These functions are not available on Windows.
2014-01-20Merge from 3.3.Stefan Krah-1/+2