summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
Commit message (Collapse)AuthorAgeFilesLines
* coalesce GILless sections in new_buffersize (#5059)Benjamin Peterson2018-01-021-5/+6
| | | 830daae1c82ed33deef0086b7b6323e5be0b0cc8 added some new GIL-releasing to new_buffersize. This is fine, but it's better to avoid reacquiring the GIL for as long as possible. Also, it should use FILE_(BEGIN|END)_ALLOW_THREADS to avoid having the file closed from under it.
* bpo-31530: fix crash when multiple threads iterate over a file, round 2 (#5060)Benjamin Peterson2018-01-021-51/+67
| | | | | | | | | | | | | | | Multiple threads iterating over a file can corrupt the file's internal readahead buffer resulting in crashes. To fix this, cache buffer state thread-locally for the duration of a file_iternext call and only update the file's internal state after reading completes. No attempt is made to define or provide "reasonable" semantics for iterating over a file on multiple threads. (Non-crashing) races are still present. Duplicated, corrupt, and missing data will happen. This was originally fixed by 6401e5671781eb217ee1afb4603cc0d1b0367ae6, which raised an exception from seek() and next() when concurrent operations were detected. Alas, this simpler solution breaks legitimate use cases such as capturing the standard streams when multiple threads are logging.
* [2.7] bpo-32186: Release the GIL during fstat and lseek calls (#4651)Nir Soffer2017-12-071-3/+18
| | | | | | | | In fileio, there were 3 fstat() calls and one lseek() call that did not release the GIL during the call. This can cause all threads to hang for unlimited time when using io.FileIO with inaccessible NFS server. Same issue seen in fileio exists also in fileobject, fixed in the same way.
* [2.7] bpo-31530: Stop crashes when iterating over a file on multiple ↵Serhiy Storchaka2017-11-101-3/+16
| | | | threads. (#3672)
* consistently use Py_TYPE, Py_REFCNT, and correct initializer macros (#3563)Benjamin Peterson2017-09-141-1/+1
| | | This no-op change makes 2.7 more consistent with 3.x to ease comparison and backports.
* Issue #23908: os functions, open() and the io.FileIO constructor now rejectSerhiy Storchaka2016-07-011-1/+2
| | | | | unicode paths with embedded null character on Windows instead of silently truncate them.
* Issue #27171: Fix typos in documentation, code comments, and testsMartin Panter2016-06-021-1/+1
|
* Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREFSerhiy Storchaka2016-04-101-2/+2
| | | | in places where Py_DECREF was used.
* Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka2016-04-061-2/+2
|
* Issue #20440: Massive replacing unsafe attribute setting code with specialSerhiy Storchaka2015-12-241-4/+2
| | | | macro Py_SETREF.
* use Py_ssize_t for file offset and length computations in iteration (closes ↵Benjamin Peterson2014-10-011-8/+7
| | | | #22526)
* Issue #21350: Fix file.writelines() to accept arbitrary buffer objects, as ↵Antoine Pitrou2014-05-081-7/+7
| | | | | | advertised. Patch by Brian Kearns.
* Circumventing a bug in glibc (issue #17976).Serhiy Storchaka2013-12-171-3/+5
| | | | Patch by Jaakko Moisio.
* Issue #17976: Fixed potential problem with file.write() not detecting IO errorSerhiy Storchaka2013-12-171-1/+5
| | | | | by inspecting the return value of fwrite(). Based on patches by Jaakko Moisio and test by Victor Stinner.
* Issue #15989: Fix several occurrences of integer overflowSerhiy Storchaka2013-01-191-4/+4
| | | | | | | when result of PyInt_AsLong() or PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277.
* get the core to compile --disable-unicodeBenjamin Peterson2013-01-021-1/+3
|
* Fixes issue #12268 for file readline, readlines and read() and readinto methods.Gregory P. Smith2012-06-261-4/+61
| | | | | | They no longer lose data when an underlying read system call is interrupted. IOError is no longer raised due to a read system call returning EINTR from within these methods.
* Issue #14505: Fix file descriptor leak when deallocating file objects ↵Antoine Pitrou2012-04-051-1/+2
| | | | created with PyFile_FromString().
* #14161: fix compile error under Windows.Ezio Melotti2012-03-111-1/+2
|
* #14161: fix the __repr__ of file objects to escape the file name.Ezio Melotti2012-03-111-4/+10
|
* Issue #13159: Replace FileIO's quadratic-time buffer growth algorithm with a ↵Nadeem Vawda2011-10-131-15/+4
| | | | | | linear-time one. Also fix the builtin file class and the bz2 module, which used the same algorithm.
* Issue #7732: Fix a crash on importing a module if a directory has the same nameVictor Stinner2011-09-231-13/+19
| | | | | | | | than a Python module (e.g. "__init__.py"): don't close the file twice. PyFile_FromFile() does also close the file if PyString_FromString() failed. It did already close the file on fill_file_fields() error (e.g. if the file is a directory).
* Issue #9295: Fix a crash under Windows when calling close() on a fileAntoine Pitrou2010-10-281-0/+6
| | | | object with custom buffering from two threads at once.
* iterators passed to writelines() can close their files; don't segfault #10125Benjamin Peterson2010-10-161-0/+5
|
* Issue #4947: The write() method of sys.stdout and sys.stderr uses theirVictor Stinner2010-09-081-4/+33
| | | | | encoding and errors attributes instead of using utf-8 in strict mode, to get the same behaviour than the print statement.
* Issue #7079: Fix a possible crash when closing a file object while usingAntoine Pitrou2010-05-171-2/+4
| | | | it from another thread. Patch by Daniel Stutzbach.
* Untabify C files. Will watch buildbots.Antoine Pitrou2010-05-091-2002/+2002
|
* more _PyString_Resize error checkingBenjamin Peterson2010-04-031-8/+10
|
* #7706: DONT_HAVE_ERRNO_H is no longer defined by configure (after rev.46819).Andrew M. Kuchling2010-02-221-1/+1
|
* Issue #5677: Explicitly forbid write operations on read-only file objects,Antoine Pitrou2010-02-051-0/+32
| | | | | | and read operations on write-only file objects. On Windows, the system C library would return a bogus result; on Solaris, it was possible to crash the interpreter. Patch by Stefan Krah.
* Issue #6368: Fixed unused variable warning on Unix.Hirokazu Yamamoto2009-06-291-0/+2
|
* Issue #4856: Remove checks for win NT.Hirokazu Yamamoto2009-06-281-19/+11
|
* Issue #3527: Removed Py_WIN_WIDE_FILENAMES which is not used any more.Hirokazu Yamamoto2009-05-171-1/+1
|
* issue 4804: Provide checks for the format string of strftime, and for the ↵Kristján Valur Jónsson2009-02-041-1/+88
| | | | "mode" string of fopen on Windows. These strings are user provided from python and so we can avoid invoking the C runtime invalid parameter handler by first checking that they are valid.
* #4764 set IOError.filename when trying to open a directory on POSIX platformsBenjamin Peterson2008-12-291-2/+2
|
* #3965: on Windows, open() crashes if the filename or the mode is invalid,Amaury Forgeot d'Arc2008-09-251-4/+11
| | | | | | and if the filename is a unicode string. Reviewed by Martin von Loewis.
* Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,Martin v. Löwis2008-08-121-2/+16
| | | | | | | by denying s# to parse objects that have a releasebuffer procedure, and introducing s*. More module might need to get converted to use s*.
* More reverting of r63675 per the mailing list discussions. This restoresGregory P. Smith2008-06-101-3/+3
| | | | | occurances of PyBytes_ in the code to their original PyString_ names. The bytesobject.c file will be renamed back to stringobject.c in a future checkin.
* This reverts r63675 based on the discussion in this thread:Gregory P. Smith2008-06-091-54/+54
| | | | | | | http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
* New environment variable PYTHONIOENCODING.Martin v. Löwis2008-06-011-3/+32
|
* Renamed PyString to PyBytesChristian Heimes2008-05-261-56/+56
|
* #2353: raise Py3k warning in file.xreadlines().Georg Brandl2008-05-171-3/+12
|
* A little reformating of Py3k warningsBenjamin Peterson2008-04-271-2/+3
|
* Use PyErr_WarnPy3k throughoutBenjamin Peterson2008-04-271-6/+2
|
* Make file objects as thread safe as the underlying libc FILE* implementation.Gregory P. Smith2008-04-061-81/+164
| | | | | | | | | | | close() will now raise an IOError if any operations on the file object are currently in progress in other threads. Most code was written by Antoine Pitrou (pitrou). Additional testing, documentation and test suite cleanup done by me (gregory.p.smith). Fixes issue 815646 and 595601 (as well as many other bugs and references to this problem dating back to the dawn of Python).
* #2348: add py3k warning for file.softspace.Georg Brandl2008-03-211-2/+34
|
* Remove all traces of HAVE_STRERROR.Brett Cannon2008-03-181-8/+0
| | | | | The removal of strerror.c led to the function check being removed from configure.in.
* Fix the IOError message text when opening a file with an invalid filename.Gregory P. Smith2008-03-181-2/+5
| | | | Error reported by Ilan Schnell.
* #2067: file.__exit__() now calls subclasses' close() method.Georg Brandl2008-02-231-2/+2
|
* static PyObject* variables should use PyString_InternFromString() instead of ↵Christian Heimes2008-01-281-1/+1
| | | | PyObject_FromString() to store a python string in a function level static var.