summaryrefslogtreecommitdiffstats
path: root/Modules/cStringIO.c
Commit message (Collapse)AuthorAgeFilesLines
* Crashers of the day: Py_CLEAR must be used when there is a chance that theAmaury Forgeot d'Arc2008-02-161-2/+1
| | | | | | | | | | | | | | | | | | | | | | | function can be called recursively. This was discussed in issue1020188. In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect, except when they appear in tp_new or tp_dealloc functions, or when the member cannot be of a user-defined class. Note that tp_init is not safe. I do have a (crashing) example for every changed line. Is it worth adding them to the test suite? Example: class SpecialStr(str): def __del__(self): s.close() import cStringIO s = cStringIO.StringIO(SpecialStr("text")) s.close() # Segfault
* #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and ↵Christian Heimes2007-12-191-2/+2
| | | | Py_REFCNT. Macros for b/w compatibility are available.
* Fix compilation warning.Georg Brandl2007-08-081-1/+1
|
* Revert the fix for #1548891, it broke backwards compatibility with arbitrary ↵Georg Brandl2007-08-081-2/+5
| | | | | | read buffers. Fixes #1730114.
* PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis2007-07-211-6/+4
| | | | | backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
* Merge change 54909 from release25-maint: Fix several minor issues ↵Kristján Valur Jónsson2007-04-251-4/+12
| | | | discovered using code analysis in VisualStudio 2005 Team Edition
* Make cStringIO.truncate raise IOError for negativeMartin v. Löwis2006-11-191-1/+11
| | | | | arguments (even for -1). Fixes the last bit of #1359365.
* newIobject(): repaired incorrect cast to quiet MSVC warning.Tim Peters2006-10-181-1/+1
|
* Bug #1548891: The cStringIO.StringIO() constructor now encodes unicodeGeorg Brandl2006-10-121-4/+2
| | | | | arguments with the system default encoding just like the write() method does, instead of converting it to a raw buffer.
* Remove unnecessary casts from type object initializers.Georg Brandl2006-03-301-13/+13
|
* SF patch #1359365: cStringIO.StringIO.isatty() will raise a ValueErrorWalter Dörwald2006-03-151-1/+2
| | | | now if close() has been called before (like file and StringIO.StringIO do)
* SF #1444030: Fix several potential defects found by Coverity.Hye-Shik Chang2006-03-071-0/+1
| | | | (reviewed by Neal Norwitz)
* Remove UNLESS.Martin v. Löwis2006-03-011-29/+28
|
* Silence gcc (4.0.x) warning about use of uninitialized value.Thomas Wouters2006-03-011-1/+1
|
* Use Py_ssize_t for counts and sizes.Martin v. Löwis2006-02-161-3/+3
|
* Merge ssize_t branch.Martin v. Löwis2006-02-151-24/+31
|
* Check return result from Py_InitModule*(). This API can fail.Neal Norwitz2006-01-191-0/+1
| | | | Probably should be backported.
* Add const to several API functions that take char *.Jeremy Hylton2005-12-101-1/+1
| | | | | | | | | | | | | | | | | | | 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 *.
* Patches #1298449 and #1298499: Add some missing checks for errorMichael W. Hudson2005-09-221-7/+15
| | | | | | returns in cStringIO.c. Thanks to Andrew Bennetts. This must be a backport candidate.
* Patch 1012740: cStringIO's truncate doesn'tTim Peters2004-08-211-0/+1
| | | | | | | | | | | | | truncate() left the stream position unchanged, which meant the "truncated" data didn't go away: >>> io.write('abc') >>> io.truncate(0) >>> io.write('xyz') >>> io.getvalue() 'abcxyz' Patch by Dima Dorfman.
* sizeof(char) is 1, by definition, so get rid of that expression inTim Peters2004-06-271-5/+4
| | | | places it's just noise.
* SF patch #907403: Improvements to cStringIO.writelines()Raymond Hettinger2004-03-081-28/+23
| | | | | | | The writelines() method now accepts any iterable argument and writes the lines one at a time rather than using ''.join(lines) followed by a single write. Results in considerable memory savings and makes the method suitable for use with generator expressions.
* Speed-up the joiner call by avoiding Py_BuildValue().Raymond Hettinger2004-02-271-1/+5
|
* Simplify and speedup uses of Py_BuildValue():Raymond Hettinger2003-10-121-1/+1
| | | | | | * 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)
* reverting to 2.41 version (distinct tp_names) - will add verbiage to theSkip Montanaro2003-08-111-2/+2
| | | | docs
* shit - just change the visible name, not the comments - strictly speaking,Skip Montanaro2003-08-111-3/+3
| | | | | the tp_name is not correct, but what's exposed to users is known visibly as "StringIO", not "StringI" or "StringO".
* typosSkip Montanaro2003-08-111-3/+3
|
* SF bug #770485: cStringIO does not set closed attrRaymond Hettinger2003-08-081-2/+22
|
* SF patch 695710: fix bug 678519: cStringIO self iteratorRaymond Hettinger2003-04-241-65/+56
| | | | (requested by GvR. patch contributed by Michael Stone)
* SF patch 660559: Use METH_O and METH_NOARGS where possibleRaymond Hettinger2003-01-031-33/+19
| | | | | Simplify code and speed access by using PyArg_UnpackTuple, METH_O and METH_NOARGS in three modules that can benefit from it.
* SF bug 601775 - some int results that should be bool.Guido van Rossum2002-09-011-1/+2
|
* Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototypeMark Hammond2002-08-021-3/+3
| | | | | | for Py_Main(). Thanks to Kalle Svensson and Skip Montanaro for the patches.
* Patch #568124: Add doc string macros.Martin v. Löwis2002-06-131-48/+35
|
* See discussion at SF bug 547537.Guido van Rossum2002-04-291-1/+1
| | | | | | | | | | | Unicode objects are currently taken as binary data by the write() method. This is not what Unicode users expect, nor what the StringIO.py code does. Until somebody adds a way to specify binary or text mode for cStringIO objects, change the format string to use "t#" instead of "s#", so that it will request the "text buffer" version. This will try the default encoding for Unicode objects. This is *not* a 2.2 bugfix (since it *is* a semantic change).
* Removed old Digital Creations copyright/license notices (withGuido van Rossum2002-04-041-53/+0
| | | | | permission from Paul Everitt). Also removed a few other references to Digital Creations and changed the remaining ones to Zope Corporation.
* Fix SF bug #526518Jeremy Hylton2002-03-081-1/+1
| | | | | | | | The doc string for cStringIO suggested that str() of a StringIO object was equivalent to getvalue(). This was never true, so repair the doc string. (doctest would have helped here.) Bug fix candidate for any past versions.
* Patch supplied by Burton Radons for his own SF bug #487390: ModifyingGuido van Rossum2001-12-081-2/+2
| | | | | | | | | | | | | type.__module__ behavior. This adds the module name and a dot in front of the type name in every type object initializer, except for built-in types (and those that already had this). Note that it touches lots of Mac modules -- I have no way to test these but the changes look right. Apologies if they're not. This also touches the weakref docs, which contains a sample type object initializer. It also touches the mmap test output, because the mmap type's repr is included in that output. It touches object.h to put the correct description in a comment.
* O_cwrite(): rewrote for clarity, replacing all the (Oobject *)selfGuido van Rossum2001-12-071-16/+17
| | | | | | | | | | | casts with a variable oself that has the proper type. A smart compiler may put this thing into a register. (I'm not sure what good this does except satisfy my desire to understand this function; I got a report about an uninitialized read from Insure++ about this function and it hurt my eyes to even look at it. I gotta run away or I'll get tempted to reformat the entire file...)
* StringIO patch #462596: let's [c]StringIO accept read buffers onMarc-André Lemburg2001-09-241-9/+5
| | | | input to .write() too.
* I_getiter(): Function for the tp_iter slot of Itype so thatBarry Warsaw2001-09-221-20/+45
| | | | | | cStringIO's can participate in the iterator protocol. Fill the Itype.tp_iter slot with I_getiter()
* In O_writelines: Replace use of string.joinfields with "".join.Jeremy Hylton2001-02-091-8/+11
|
* Added a new "base" type, IOobject for which most of theJim Fulton2000-10-061-285/+355
| | | | | | | | | | | | | | | operations are defined. This will, hopefully clarify some of the logic. Added close test to raise proper error when operations are performed on closed StringIOs. Added a position argument to the truncate method. Added a size argument to readline. Added PyArg_Parse calls for methods that don't take arguments to make sure they don't take arguments.
* Implement readlines function. Closes Bug #110686.Martin v. Löwis2000-09-191-0/+36
|
* Use METH_VARARGS instead of numeric constant 1 in method def. tablesAndrew M. Kuchling2000-08-031-1/+2
|
* ANSIfy some more forward declarations.Thomas Wouters2000-07-241-1/+1
|
* Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in eitherThomas Wouters2000-07-161-1/+1
| | | | | | | | | | comments, docstrings or error messages. I fixed two minor things in test_winreg.py ("didn't" -> "Didn't" and "Didnt" -> "Didn't"). There is a minor style issue involved: Guido seems to have preferred English grammar (behaviour, honour) in a couple places. This patch changes that to American, which is the more prominent style in the source. I prefer English myself, so if English is preferred, I'd be happy to supply a patch myself ;)
* replace PyXXX_Length calls with PyXXX_Size callsJeremy Hylton2000-07-121-1/+1
|
* Fixed docstring typo, reported by Skip Montanaro <skip@mojam.com>.Fred Drake2000-06-191-1/+1
|
* Vladimir Marangozov's long-awaited malloc restructuring.Guido van Rossum2000-05-031-5/+5
| | | | | | | | | | For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.)
* raise TypeError when bad argument passed to cStringIO.StringIOJeremy Hylton2000-04-121-4/+10
|