Martin Panter
6bb91f3b6e
Issue #20699 : Document that “io” methods accept bytes-like objects
...
This matches the usage of ZipFile and BufferedWriter. This still requires
return values to be bytes() objects.
Also document and test that the write() methods should only access their
argument before they return.
2016-05-28 00:41:57 +00:00
Victor Stinner
914cde89d4
On ResourceWarning, log traceback where the object was allocated
...
Issue #26567 :
* Add a new function PyErr_ResourceWarning() function to pass the destroyed
object
* Add a source attribute to warnings.WarningMessage
* Add warnings._showwarnmsg() which uses tracemalloc to get the traceback where
source object was allocated.
2016-03-19 01:03:51 +01:00
Serhiy Storchaka
ef1585eb9a
Issue #25923 : Added more const qualifiers to signatures of static and private functions.
2015-12-25 20:01:53 +02:00
Martin Panter
49d3db92a4
Issue #25717 : Add comment explaining why errors are ignored
2015-12-06 11:12:15 +00:00
Martin Panter
0bb62b12a3
Issue #25717 : Tolerate fstat() failures in the FileIO constructor
...
This restores 3.4 behaviour, which was removed by revision 3b5279b5bfd1. The
fstat() call fails with ENOENT for a Virtual Box shared folder filesystem if
the file entry has been unlinked, e.g. for a temporary file.
2015-12-06 03:15:05 +00:00
Larry Hastings
dbfdc380df
Issue #24001 : Argument Clinic converters now use accept={type}
...
instead of types={'type'} to specify the types the converter accepts.
2015-05-04 06:59:46 -07:00
Serhiy Storchaka
7e9d1d1a1b
Issue #23908 : os functions now reject paths with embedded null character
...
on Windows instead of silently truncate them.
Removed no longer used _PyUnicode_HasNULChars().
2015-04-20 10:12:28 +03:00
Serhiy Storchaka
2b0d2007a1
Issue #23908 : os functions now reject paths with embedded null character
...
on Windows instead of silently truncate them.
2015-04-20 09:53:58 +03:00
Christian Heimes
82adeffc13
Fix typo in assert statement
2015-04-16 17:21:54 +02:00
Serhiy Storchaka
f24131ff31
Issue #20175 : Converted the _io module to Argument Clinic.
2015-04-16 11:19:43 +03:00
Steve Dower
a1c7e727c8
Issue #23668 : Suppresses invalid parameter handler around chsize calls.
2015-04-12 00:26:43 -04:00
Steve Dower
8fc8980c96
Issue #23524 : Replace _PyVerify_fd function with calls to _set_thread_local_invalid_parameter_handler.
2015-04-12 00:26:27 -04:00
Serhiy Storchaka
3d2279f9a8
Issue #21859 : Corrected FileIO docstrings.
2015-04-10 16:08:43 +03:00
Steve Dower
fe0a41aae4
Issue #23668 : Adds support for os.truncate and os.ftruncate on Windows
2015-03-20 19:50:46 -07:00
Serhiy Storchaka
cd092efb16
Issue #21859 : Corrected FileIO docstrings.
2015-04-10 16:09:13 +03:00
Serhiy Storchaka
5056769b36
Replaced "string" with "bytes object" in docstrings of binary I/O objects.
2015-04-10 02:19:57 +03:00
Serhiy Storchaka
b817b77a8c
Replaced "string" with "bytes object" in docstrings of binary I/O objects.
2015-04-10 02:18:44 +03:00
Victor Stinner
e134a7fe36
Issue #23752 : _Py_fstat() is now responsible to raise the Python exception
...
Add _Py_fstat_noraise() function when a Python exception is not welcome.
2015-03-30 10:09:31 +02:00
Victor Stinner
520bddf79a
Issue #23752 : When built from an existing file descriptor, io.FileIO() now only
...
calls fstat() once. Before fstat() was called twice, which was not necessary.
2015-03-30 03:21:06 +02:00
Victor Stinner
f329878e74
Issue #23753 : Python doesn't support anymore platforms without stat() or
...
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-24 10:27:50 +01:00
Victor Stinner
66aab0c4b5
Issue #23708 : Add _Py_read() and _Py_write() functions to factorize code handle
...
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-19 22:53:20 +01:00
Steve Dower
8acde7dcce
Issue #23524 : Change back to using Windows errors for _Py_fstat instead of the errno shim.
2015-03-07 18:14:07 -08:00
Steve Dower
d81431f587
Issue #23524 : Replace _PyVerify_fd function with calling _set_thread_local_invalid_parameter_handler on every thread.
2015-03-06 14:47:02 -08:00
Victor Stinner
9672da7bb4
Issue #23285 : Fix handling of EINTR in fileio.c
...
Fix handling of EINTR: don't return None if PyErr_CheckSignals() raised an
exception.
Initialize also the length outside the loop to only initialize it once.
2015-03-04 18:40:10 +01:00
Steve Dower
f2f373f593
Issue #23152 : Implement _Py_fstat() to support files larger than 2 GB on Windows.
...
fstat() may fail with EOVERFLOW on files larger than 2 GB because the file size type is an signed 32-bit integer.
2015-02-21 08:44:05 -08:00
Serhiy Storchaka
254dd59068
Issue #5700 : io.FileIO() called flush() after closing the file.
...
flush() was not called in close() if closefd=False.
2015-02-21 00:35:53 +02:00
Serhiy Storchaka
a3712a9a6c
Issue #5700 : io.FileIO() called flush() after closing the file.
...
flush() was not called in close() if closefd=False.
2015-02-21 00:35:09 +02:00
Charles-François Natali
6e6c59b508
Issue #23285 : PEP 475 -- Retry system calls failing with EINTR.
2015-02-07 13:27:50 +00:00
Serhiy Storchaka
4954f9fcab
Issue #17401 : Output the closefd attribute as boolean.
2014-12-02 23:39:56 +02:00
Robert Collins
933430ab69
Issue #17401 : document closefd in io.FileIO docs and add to repr
...
closefd was documented in the open docs but not the matching FileIO
class documented. Further, closefd, part of the core state for the
object was not shown.
In review it was noted that the open docs are a little confusing about
the interaction between closefd and paths, so tweaked them at the same
time.
2014-10-18 13:32:43 +13:00
Berker Peksag
43705d76aa
Issue #21860 : Correct docstrings of FileIO.seek() and FileIO.truncate() methods.
...
Patch by Terry Chia.
2014-09-24 12:44:06 +03:00
Berker Peksag
b87630c273
Issue #21860 : Correct docstrings of FileIO.seek() and FileIO.truncate() methods.
...
Patch by Terry Chia.
2014-09-24 12:43:29 +03:00
Serhiy Storchaka
d8a1447c99
Issue #22215 : Now ValueError is raised instead of TypeError when str or bytes
...
argument contains not permitted null character or byte.
2014-09-06 20:07:17 +03:00
Victor Stinner
6680e9f5fd
(Merge 3.4) Issue #21090 : io.FileIO.readall() does not ignore I/O errors
...
anymore. Before, it ignored I/O errors if at least the first C call read()
succeed.
2014-07-02 23:00:38 +02:00
Victor Stinner
e10920f0d1
Issue #21090 : io.FileIO.readall() does not ignore I/O errors anymore. Before,
...
it ignored I/O errors if at least the first C call read() succeed.
2014-07-02 22:59:31 +02:00
Antoine Pitrou
de68722ca0
Issue #21679 : Prevent extraneous fstat() calls during open(). Patch by Bohuslav Kabrda.
2014-06-29 20:07:28 -04:00
Antoine Pitrou
712cb734bd
Issue #20037 : Avoid crashes when doing text I/O late at interpreter shutdown.
2013-12-21 15:51:54 +01:00
Victor Stinner
d9d0419a9f
Issue #19512 : fileio_init() reuses PyId_name identifier instead of "name"
...
literal string
2013-11-06 23:50:10 +01:00
Antoine Pitrou
e619427f7e
Issue #18876 : The FileIO.mode attribute now better reflects the actual mode under which the file was opened.
...
Patch by Erik Bray.
2013-09-04 20:52:14 +02:00
Antoine Pitrou
e93b63b74b
Issue #18876 : The FileIO.mode attribute now better reflects the actual mode under which the file was opened.
...
Patch by Erik Bray.
2013-09-04 20:46:33 +02:00
Victor Stinner
daf455554b
Issue #18571 : Implementation of the PEP 446: file descriptors and file handles
...
are now created non-inheritable; add functions os.get/set_inheritable(),
os.get/set_handle_inheritable() and socket.socket.get/set_inheritable().
2013-08-28 00:53:59 +02:00
Antoine Pitrou
796564c27b
Issue #18112 : PEP 442 implementation (safe object finalization).
2013-07-30 19:59:21 +02:00
Victor Stinner
85c761d3d3
Issue #18408 : Fix fileio_read() on _PyBytes_Resize() failure
...
bytes is NULL on _PyBytes_Resize() failure
2013-07-16 21:36:02 +02:00
Victor Stinner
14b9b11098
If MS_WIN64 is defined, MS_WINDOWS is also defined: #ifdef can be simplified.
2013-06-25 00:37:25 +02:00
Christian Heimes
9975877f46
Check for correct macro, code uses S_ISDIR().
2013-06-23 23:52:40 +02:00
Christian Heimes
91e8b8180d
Check for correct macro, code uses S_ISDIR().
2013-06-23 23:51:44 +02:00
Victor Stinner
3e269397e3
FileIO.readall(): remove trailing space from an exception message
2013-05-18 00:38:43 +02:00
Richard Oudkerk
af7260e81a
Issue #15758 : Fix FileIO.readall() so it no longer has O(n**2) complexity.
2013-05-17 23:34:42 +01:00
Serhiy Storchaka
9101e23ff6
Issue #15989 : Fix several occurrences of integer overflow
...
when result of PyLong_AsLong() narrowed to int without checks.
This is a backport of changesets 13e2e44db99d and 525407d89277.
2013-01-19 12:41:45 +02:00
Serhiy Storchaka
441d30fac7
Issue #15989 : Fix several occurrences of integer overflow
...
when result of PyLong_AsLong() narrowed to int without checks.
This is a backport of changesets 13e2e44db99d and 525407d89277.
2013-01-19 12:26:26 +02:00
Serhiy Storchaka
7898043868
Issue #15989 : Fix several occurrences of integer overflow
...
when result of PyLong_AsLong() narrowed to int without checks.
2013-01-15 01:12:17 +02:00
Victor Stinner
fd53a5a011
(Merge 3.3) Issue #16367 : Fix FileIO.readall() on Windows for files larger than 2 GB.
2013-01-03 03:38:38 +01:00
Victor Stinner
6f84659e5e
(Merge 3.2) Issue #16367 : Fix FileIO.readall() on Windows for files larger than 2 GB.
2013-01-03 03:37:47 +01:00
Victor Stinner
c44057dfbd
Issue #16367 : Fix FileIO.readall() on Windows for files larger than 2 GB
2013-01-03 03:33:21 +01:00
Victor Stinner
292c835548
Issue #15478 : Raising an OSError doesn't decode or encode the filename anymore
...
Pass the original filename argument to OSError constructor, instead of trying
to encode it to or decode it from the filesystem encoding. This change avoids
an additionnal UnicodeDecodeError on Windows if the filename cannot be decoded
from the filesystem encoding (ANSI code page).
2012-10-30 02:17:38 +01:00
Antoine Pitrou
7d7f40c613
Issue #15247 : FileIO now raises an error when given a file descriptor pointing to a directory.
2012-07-06 18:52:58 +02:00
Antoine Pitrou
9235b254dc
Issue #15247 : FileIO now raises an error when given a file descriptor pointing to a directory.
2012-07-06 18:48:24 +02:00
Gregory P. Smith
990a5feba7
Fixes issue #12268 : File readline, readlines and read() or readall() methods
...
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.
2012-06-24 00:23:47 -07:00
Gregory P. Smith
5135992164
Fixes issue #12268 : File readline, readlines and read() or readall() methods
...
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.
2012-06-23 23:55:39 -07:00
Hynek Schlawack
7f59fd7c7c
Simplify code in fileio_init
...
If an identical code line is in both at the end of if and else, it can as well
stand after the block. :) The code is from 464cf523485e, I didn't see it before
checking the commits in the web interface of course.
2012-06-22 09:32:22 +02:00
Hynek Schlawack
69168354c2
#10053 : Don't close FDs when FileIO.__init__ fails
...
Loosely based on the work by Hirokazu Yamamoto.
2012-06-21 20:58:31 +02:00
Hynek Schlawack
9ed8b4e4ca
#10053 : Don't close FDs when FileIO.__init__ fails
...
Loosely based on the work by Hirokazu Yamamoto.
2012-06-21 20:20:25 +02:00
Hynek Schlawack
9866d96e48
#4841 : Fix FileIO constructor to honor closefd when called repeatedly
...
Patch by Victor Stinner.
2012-05-25 10:27:43 +02:00
Hynek Schlawack
2cc7156515
#4841 : Fix FileIO constructor to honor closefd when called repeatedly
...
Patch by Victor Stinner.
2012-05-25 10:05:53 +02:00
Antoine Pitrou
a3f4457b17
Speed up reading of small files. This avoids multiple C read() calls on pyc files.
2012-04-17 13:50:58 +02:00
Antoine Pitrou
7ab4af0427
Issue #13848 : open() and the FileIO constructor now check for NUL characters in the file name.
...
Patch by Hynek Schlawack.
2012-01-29 18:43:36 +01:00
Antoine Pitrou
1334884ff2
Issue #13848 : open() and the FileIO constructor now check for NUL characters in the file name.
...
Patch by Hynek Schlawack.
2012-01-29 18:36:34 +01:00
Charles-François Natali
d612de10e5
Issue #12760 : Refer to the new 'x' open mode as "exclusive creation" mode.
2012-01-14 11:51:00 +01:00
Charles-François Natali
dc3044c704
Issue #12760 : Add a create mode to open(). Patch by David Townshend.
2012-01-09 22:40:02 +01:00
Antoine Pitrou
ab0e9f7089
Issue #10350 : Read and save errno before calling a function which might overwrite it.
...
Original patch by Hallvard B Furuseth.
2011-12-16 12:29:37 +01:00
Antoine Pitrou
c345ce1a69
Issue #10350 : Read and save errno before calling a function which might overwrite it.
...
Original patch by Hallvard B Furuseth.
2011-12-16 12:28:32 +01:00
Martin v. Löwis
767046aab1
Replace {Get,Set,Has}AttrString with *AttrId.
2011-10-14 15:35:36 +02:00
Ross Lagerwall
59142db6d3
Issue #12797 : Added custom opener parameter to builtin open() and FileIO.open().
2011-10-31 20:34:46 +02:00
Martin v. Löwis
bd928fef42
Rename _Py_identifier to _Py_IDENTIFIER.
2011-10-14 10:20:37 +02:00
Nadeem Vawda
72d6a13413
Merge #13159 : Replace FileIO's quadratic-time buffer growth algorithm with a linear-time one.
...
Also fix the bz2 module, which suffered from the same problem.
2011-10-13 13:38:14 +02:00
Nadeem Vawda
d41a98bdd9
Issue #13159 : Replace FileIO's quadratic-time buffer growth algorithm with a linear-time one.
...
Also fix the bz2 module, whose classes used the same algorithm.
2011-10-13 13:34:16 +02:00
Victor Stinner
c5af7730e3
Fix FileIO.readall() (new_buffersize()) for large files
...
Truncate the buffer size to PY_SSIZE_T_MAX.
2011-10-11 23:00:31 +02:00
Victor Stinner
a2a6477ba0
Fix io.FileIO.readall() on Windows 64 bits
...
Use Py_off_t type (64 bits) instead of off_t (32 bits).
2011-10-11 22:45:02 +02:00
Martin v. Löwis
afe55bba33
Add API for static strings, primarily good for identifiers.
...
Thanks to Konrad Schöbel and Jasper Schulz for helping with the mass-editing.
2011-10-09 10:38:36 +02:00
Victor Stinner
fe9a861e74
fileio_init() checks for failure on conversion to Py_UNICODE*
2011-09-29 23:19:04 +02:00
Victor Stinner
d9fc85db7f
(merge 3.2) Issue #9611 , #9015 : FileIO.read() clamps the length to INT_MAX on Windows.
2011-07-05 11:34:18 +02:00
Victor Stinner
c655a726db
Issue #9611 , #9015 : FileIO.read() clamps the length to INT_MAX on Windows.
2011-07-05 11:31:49 +02:00
Victor Stinner
e9d44ccb22
Issue #12175 : FileIO.readall() now only reads the file position and size once.
2011-05-26 00:16:44 +02:00
Victor Stinner
4767114e77
(Merge 3.1) Issue #12175 : FileIO.readall() now raises a ValueError instead of
...
an IOError if the file is closed.
2011-05-25 22:11:55 +02:00
Victor Stinner
b79f28ccbd
Issue #12175 : FileIO.readall() now raises a ValueError instead of an IOError if
...
the file is closed.
2011-05-25 22:09:03 +02:00
Victor Stinner
e0daff1c61
Issue #11395 : io.FileIO().write() clamps the data length to 32,767 bytes on
...
Windows if the file is a TTY to workaround a Windows bug. The Windows console
returns an error (12: not enough space error) on writing into stdout if
stdout mode is binary and the length is greater than 66,000 bytes (or less,
depending on heap usage).
2011-03-20 23:36:35 +01:00
Victor Stinner
7234479580
Issue #9611 : remove useless and dangerous explicit conversion to size_t
2011-01-11 00:04:12 +00:00
Victor Stinner
89e3436606
Issue #10841 : set binary mode on files; the parser translates newlines
...
On Windows, set the binary mode on stdin, stdout, stderr and all
io.FileIO objects (to not translate newlines, \r\n <=> \n). The Python parser
translates newlines (\r\n => \n).
2011-01-07 18:47:22 +00:00
Victor Stinner
e6edec2371
Issue #9015 , #9611 : FileIO.readinto(), FileIO.write() and os.write() clamp the
...
length to 2^31-1 on Windows.
2011-01-04 00:29:35 +00:00
Georg Brandl
d62ecbf0ba
Merged revisions 85728,85731,85735,85766-85771,85773,85777 via svnmerge from
...
svn+ssh://svn.python.org/python/branches/py3k
........
r85728 | georg.brandl | 2010-10-19 20:54:25 +0200 (Di, 19 Okt 2010) | 1 line
#10092 : Properly reset locale in Locale*Calendar classes. The context manager was buggy because setlocale() returns the *new* locale, not the old. Also add a test for this.
........
r85731 | georg.brandl | 2010-10-19 23:07:16 +0200 (Di, 19 Okt 2010) | 1 line
Be consistent in the spelling of thread-safe(ty).
........
r85735 | georg.brandl | 2010-10-20 08:50:19 +0200 (Mi, 20 Okt 2010) | 1 line
Fix r85728: use "" to mean the system default locale, which should work on more systems.
........
r85766 | georg.brandl | 2010-10-21 09:40:03 +0200 (Do, 21 Okt 2010) | 1 line
#10159 : sort completion matches before comparing to dir() result.
........
r85767 | georg.brandl | 2010-10-21 14:49:28 +0200 (Do, 21 Okt 2010) | 1 line
#9095 , #8912 , #8999 : add support in patchcheck for Mercurial checkouts, C file reindenting, and docs whitespace fixing.
........
r85768 | georg.brandl | 2010-10-21 14:59:14 +0200 (Do, 21 Okt 2010) | 1 line
#9919 : fix off-by-one error in lineno command in Misc/gdbinit; also add newline to its output.
........
r85769 | georg.brandl | 2010-10-21 15:01:23 +0200 (Do, 21 Okt 2010) | 1 line
Fix missing import.
........
r85770 | georg.brandl | 2010-10-21 15:29:10 +0200 (Do, 21 Okt 2010) | 1 line
#3077 : fix h2py substitution of character literals.
........
r85771 | georg.brandl | 2010-10-21 15:34:51 +0200 (Do, 21 Okt 2010) | 1 line
#1203650 : allow larger list of files in windows makefile for freeze.
........
r85773 | georg.brandl | 2010-10-21 15:45:52 +0200 (Do, 21 Okt 2010) | 1 line
#4829 : better error message for invalid file mode
........
r85777 | georg.brandl | 2010-10-21 17:44:51 +0200 (Do, 21 Okt 2010) | 1 line
Add .hgeol file for the Mercurial EOL extension.
........
2010-11-26 08:52:36 +00:00
Antoine Pitrou
243757eb79
Issue #10180 : Pickling file objects is now explicitly forbidden, since
...
unpickling them produced nonsensical results.
2010-11-05 21:15:39 +00:00
Antoine Pitrou
735e3b195a
Merged revisions 85982 via svnmerge from
...
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85982 | antoine.pitrou | 2010-10-30 18:19:14 +0200 (sam., 30 oct. 2010) | 4 lines
Issue #10253 : FileIO leaks a file descriptor when trying to open a file
for append that isn't seekable. Patch by Brian Brazil.
........
2010-10-31 13:05:21 +00:00
Benjamin Peterson
bbb0412ad1
if FileIO.__init__ fails, close fd
2010-10-30 23:16:28 +00:00
Benjamin Peterson
430d469758
fix style
2010-10-30 23:13:57 +00:00
Antoine Pitrou
8d2b51b46a
Issue #10253 : FileIO leaks a file descriptor when trying to open a file
...
for append that isn't seekable. Patch by Brian Brazil.
2010-10-30 16:19:14 +00:00
Antoine Pitrou
e033e06db0
Issue #10093 : ResourceWarnings are now issued when files and sockets are
...
deallocated without explicit closing. These warnings are silenced by
default, except in pydebug mode.
2010-10-29 10:38:18 +00:00
Georg Brandl
28928aef2e
#4829 : better error message for invalid file mode
2010-10-21 13:45:52 +00:00
Antoine Pitrou
0d739d7047
Issue #9293 : I/O streams now raise `io.UnsupportedOperation` when an
...
unsupported operation is attempted (for example, writing to a file open
only for reading).
2010-09-05 23:01:12 +00:00
Victor Stinner
ae6265f8d0
Issue #8715 : Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
...
object to Py_FileSystemDefaultEncoding with the "surrogateescape" error
handler, return a bytes object. If Py_FileSystemDefaultEncoding is not set,
fall back to UTF-8.
2010-05-15 16:27:27 +00:00
Antoine Pitrou
f7ec1fd846
Merged revisions 80798 via svnmerge from
...
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r80798 | antoine.pitrou | 2010-05-05 18:31:07 +0200 (mer., 05 mai 2010) | 9 lines
Merged revisions 80796 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r80796 | antoine.pitrou | 2010-05-05 18:27:30 +0200 (mer., 05 mai 2010) | 3 lines
Untabify Modules/_io/fileio.c
........
................
2010-05-05 16:34:37 +00:00