| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
Added checks for integer overflows, contributed by Google. Some are
only available if asserts are left in the code, in cases where they
can't be triggered from Python code.
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Py_REFCNT. Macros for b/w compatibility are available.
|
| |
|
|
|
|
|
|
| |
read buffers.
Fixes #1730114.
|
|
|
|
|
| |
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
|
|
|
|
| |
discovered using code analysis in VisualStudio 2005 Team Edition
|
|
|
|
|
| |
arguments (even for -1). Fixes the last bit of
#1359365.
|
| |
|
|
|
|
|
| |
arguments with the system default encoding just like the write()
method does, instead of converting it to a raw buffer.
|
| |
|
|
|
|
| |
now if close() has been called before (like file and StringIO.StringIO do)
|
|
|
|
| |
(reviewed by Neal Norwitz)
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
Probably should be backported.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 *.
|
|
|
|
|
|
| |
returns in cStringIO.c. Thanks to Andrew Bennetts.
This must be a backport candidate.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
places it's just noise.
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
* 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)
|
|
|
|
| |
docs
|
|
|
|
|
| |
the tp_name is not correct, but what's exposed to users is known visibly as
"StringIO", not "StringI" or "StringO".
|
| |
|
| |
|
|
|
|
| |
(requested by GvR. patch contributed by Michael Stone)
|
|
|
|
|
| |
Simplify code and speed access by using PyArg_UnpackTuple, METH_O and
METH_NOARGS in three modules that can benefit from it.
|
| |
|
|
|
|
|
|
| |
for Py_Main().
Thanks to Kalle Svensson and Skip Montanaro for the patches.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
|
|
|
|
| |
permission from Paul Everitt). Also removed a few other references to
Digital Creations and changed the remaining ones to Zope Corporation.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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...)
|
|
|
|
| |
input to .write() too.
|
|
|
|
|
|
| |
cStringIO's can participate in the iterator protocol.
Fill the Itype.tp_iter slot with I_getiter()
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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 ;)
|
| |
|