summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
Commit message (Collapse)AuthorAgeFilesLines
* PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis2007-07-211-3/+2
| | | | | backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
* Export function sanitize_the_mode from fileobject.c as ↵Kristján Valur Jónsson2007-04-261-8/+7
| | | | _PyFile_SanitizeMode(). Use this function in posixmodule.c when implementing fdopen(). This fixes test_subprocess.py for a VisualStudio 2005 compile.
* SF patch #1630975: Fix crash when replacing sys.stdout in sitecustomizeThomas Wouters2007-01-231-0/+2
| | | | | | | | | | | When running the interpreter in an environment that would cause it to set stdout/stderr/stdin's encoding, having a sitecustomize that would replace them with something other than PyFile objects would crash the interpreter. Fix it by simply ignoring the encoding-setting for non-files. This could do with a test, but I can think of no maintainable and portable way to test this bug, short of adding a sitecustomize.py to the buildsystem and have it always run with it (hmmm....)
* Bug #1067760: Deprecate passing floats to file.seek.Martin v. Löwis2006-11-121-4/+17
|
* Forward-port of r52136,52138: a review of overflow-detecting code.Armin Rigo2006-10-041-2/+6
| | | | | | | | | | | | | | | | | | | | | | | * unified the way intobject, longobject and mystrtoul handle values around -sys.maxint-1. * in general, trying to entierely avoid overflows in any computation involving signed ints or longs is extremely involved. Fixed a few simple cases where a compiler might be too clever (but that's all guesswork). * more overflow checks against bad data in marshal.c. * 2.5 specific: fixed a number of places that were still confusing int and Py_ssize_t. Some of them could potentially have caused "real-world" breakage. * list.pop(x): fixing overflow issues on x was messy. I just reverted to PyArg_ParseTuple("n"), which does the right thing. (An obscure test was trying to give a Decimal to list.pop()... doesn't make sense any more IMHO) * trying to write a few tests...
* Make sure memory is properly cleaned up in file_init.Brett Cannon2006-08-311-1/+1
| | | | Backport candidate.
* Fix a couple of ssize-t issues reported by Alexander Belopolsky on python-devNeal Norwitz2006-08-211-1/+1
|
* Stop INCREFing name, then checking if it's NULL. name (f_name) should neverNeal Norwitz2006-07-171-3/+6
| | | | | | be NULL so assert it. Fix one place where we could have passed NULL. Reported by Klocwork #66.
* Handle a NULL name properly.Neal Norwitz2006-07-161-3/+3
| | | | Reported by Klocwork #67
* Fix build problems with the platform SDK on windows. It is not sufficient ↵Kristján Valur Jónsson2006-07-031-1/+1
| | | | to test for the C compiler version when determining if we have the secure CRT from microsoft. Must test with an undocumented macro, __STDC_SECURE_LIB__ too.
* Fix the CRT argument error handling for VisualStudio .NET 2005. Install a ↵Kristján Valur Jónsson2006-06-121-1/+3
| | | | | | CRT error handler and disable the assertion for debug builds. This causes CRT to set errno to EINVAL. This update fixes crash cases in the test suite where the default CRT error handler would cause process exit.
* Patch #1495999: Part two of Windows CE changes.Martin v. Löwis2006-06-101-2/+2
| | | | | | - update header checks, using autoconf - provide dummies for getenv, environ, and GetVersion - adjust MSC_VER check in socketmodule.c
* Bug #1502805: don't alias file.__exit__ to file.close since theGeorg Brandl2006-06-081-1/+18
| | | | latter can return something that's true.
* Bug #1462152: file() now checks more thoroughly for invalid modeGeorg Brandl2006-05-181-35/+48
| | | | | strings and removes a possible "U" before passing the mode to the C library function.
* Get rid of __context__, per the latest changes to PEP 343 and python-devGuido van Rossum2006-05-021-5/+0
| | | | | | | | discussion. There are two places of documentation that still mention __context__: Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without spending a whole lot of time thinking about it; and whatsnew, which Andrew usually likes to change himself.
* SF #1479181: split open() and file() from being aliases for each other.Neal Norwitz2006-05-021-4/+0
|
* Replace INT_MAX with PY_SSIZE_T_MAX where string lengthMartin v. Löwis2006-04-131-4/+4
| | | | are concerned.
* spread the extern "C" { } magic pixie dust around. Python itself builds nowAnthony Baxter2006-04-131-0/+9
| | | | | using a C++ compiler. Still lots and lots of errors in the modules built by setup.py, and a bunch of warnings from g++ in the core.
* More C++-compliance. Note especially listobject.c - to get C++ to accept theAnthony Baxter2006-04-111-5/+6
| | | | | | | | | PyTypeObject structures, I had to make prototypes for the functions, and move the structure definition ahead of the functions. I'd dearly like a better way to do this - to change this would make for a massive set of changes to the codebase. There's still some warnings - this is purely to get rid of errors first.
* Bug #1177964: make file iterator raise MemoryError on too big filesGeorg Brandl2006-03-311-1/+2
|
* Remove unnecessary casts in type object initializers.Georg Brandl2006-03-301-1/+1
|
* Um, I thought I'd already checked this in.Guido van Rossum2006-03-101-26/+1
| | | | | | | Anyway, this is the changes to the with-statement so that __exit__ must return a true value in order for a pending exception to be ignored. The PEP (343) is already updated.
* Updates to the with-statement:Guido van Rossum2006-02-281-3/+37
| | | | | | | | | | | | | | | | - New semantics for __exit__() -- it must re-raise the exception if type is not None; the with-statement itself doesn't do this. (See the updated PEP for motivation.) - Added context managers to: - file - thread.LockType - threading.{Lock,RLock,Condition,Semaphore,BoundedSemaphore} - decimal.Context - Added contextlib.py, which defines @contextmanager, nested(), closing(). - Unit tests all around; bot no docs yet.
* Revert backwards-incompatible const changes.Martin v. Löwis2006-02-271-1/+1
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-14/+19
|
* SF patch #1397960: When mixing file-iteration andThomas Wouters2006-02-121-2/+39
| | | | | | | readline/readlines/read/readinto, loudly break by raising ValueError, rather than silently deliver data out of order or hitting EOF prematurely. Probably not a bugfix candidate, even though it affects no 'working' code.
* strlen() returns a size_t, get rid of 64-bit warningNeal Norwitz2006-01-081-1/+1
|
* Revert r41662 and the part of 41552 that originally caused the problemNeal Norwitz2005-12-151-7/+0
| | | | | (calling ftell(stdin) doesn't seem defined). So we won't test errors from ftell unless we can do it portably.
* Add a workaround for file.ftell() to raise IOError for ttys.Hye-Shik Chang2005-12-131-0/+7
| | | | | ftell(3) on BSD doesn't set errno even for ttys and returns useless values.
* Add const to several API functions that take char *.Jeremy Hylton2005-12-101-3/+4
| | | | | | | | | | | | | | | | | | | In C++, it's an error to pass a string literal to a char* function without a const_cast(). Rather than require every C++ extension module to put a cast around string literals, fix the API to state the const-ness. I focused on parts of the API where people usually pass literals: PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type slots, etc. Predictably, there were a large set of functions that needed to be fixed as a result of these changes. The most pervasive change was to make the keyword args list passed to PyArg_ParseTupleAndKewords() to be a const char *kwlist[]. One cast was required as a result of the changes: A type object mallocs the memory for its tp_doc slot and later frees it. PyTypeObject says that tp_doc is const char *; but if the type was created by type_new(), we know it is safe to cast to char *.
* Disallow opening files with modes 'aU' or 'wU' as specified by PEPSkip Montanaro2005-05-201-0/+51
| | | | 278. Closes bug 967182.
* If close() fails in file_dealloc, then print an error message toPeter Astrand2004-11-071-1/+8
| | | | | stderr. close() can fail if the user is out-of-quota, for example. Fixes #959379.
* dump HAVE_FOPENRF stuff - obsoleteSkip Montanaro2004-06-111-26/+19
|
* Add weakref support to array.array and file objects.Raymond Hettinger2004-05-311-2/+5
|
* If a file is opened with an explicit buffer size >= 1, repeatedAndrew MacIntyre2004-04-041-0/+2
| | | | | | | | close() calls would attempt to free() the buffer already free()ed on the first close(). [bug introduced with patch #788249] Making sure that the buffer is free()ed in file object deallocation is a belt-n-braces bit of insurance against a memory leak.
* Changed file.name to be the object passed as the 'name' argument to file()Nicholas Bastin2004-03-211-17/+21
| | | | Fixes SF Bug #773356
* PyFile_WriteObject(): some of the local variables are only used whenFred Drake2004-03-191-0/+2
| | | | Py_USING_UNICODE is defined
* Remove support for --without-universal-newlines (see PEP 11).Skip Montanaro2004-02-071-35/+0
|
* Getting rid of code dependent on GUSI or the MetroWerks compiler.Jack Jansen2003-11-191-28/+0
|
* Patch #809535: Mention behaviour of seek on text files. Backported to 2.3.Martin v. Löwis2003-10-181-1/+3
|
* Simplify and speedup uses of Py_BuildValue():Raymond Hettinger2003-10-121-2/+2
| | | | | | * Py_BuildValue("(OOO)",a,b,c) --> PyTuple_Pack(3,a,b,c) * Py_BuildValue("()",a) --> PyTuple_New(0) * Py_BuildValue("O", a) --> Py_INCREF(a)
* Only release buffer after file has been closed. Fixes #800824.Martin v. Löwis2003-09-071-1/+1
| | | | Will backport to 2.2.
* SF bug 801631: file.truncate fault on windows.Tim Peters2003-09-071-74/+66
| | | | | | | | | | | | | | | | | file_truncate(): C doesn't define what fflush(fp) does if fp is open for update, and the preceding I/O operation on fp was input. On Windows, fflush() actually changes the current file position then. Because Windows doesn't support ftruncate() directly, this not only caused Python's file.truncate() to change the file position (contra our docs), it also caused the file not to change size. Repaired by getting the initial file position at the start, restoring it at the end, and tossing all the complicated micro-efficiency checks trying to avoid "provably unnecessary" seeks. file.truncate() can't be a frequent operation, and seeking to the current file position has got to be cheap anyway. Bugfix candidate.
* Patch #788249: Pass an explicit buffer to setvbuf in PyFile_SetBufSize().Martin v. Löwis2003-09-041-5/+19
| | | | Fixes #603724. Will backport to 2.3.
* Fix SF #789402, Memory leak on open()Neal Norwitz2003-08-151-0/+1
| | | | If opening a directory, the exception would leak.
* Only encode Unicode objects when printing them raw.Martin v. Löwis2003-05-181-1/+2
|
* Patch #612627: Add encoding attribute to file objects, and determineMartin v. Löwis2003-05-101-1/+41
| | | | the terminal encoding on Windows and Unix.
* Somewhere along the way, the softspace attr of file objects became read-Tim Peters2003-05-041-1/+2
| | | | only. Repaired, and added new tests to test_file.py.
* SF patch #683187, fix universal newline problems on errorNeal Norwitz2003-02-091-1/+4
|
* Allow PyFile_GetLine() to return Unicode objects. Fixes #660165.Martin v. Löwis2003-01-031-1/+24
|