Commit Graph

52 Commits

Author SHA1 Message Date
Antoine Pitrou c7c96a90bc Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines

  Untabify C files. Will watch buildbots.
........
2010-05-09 15:15:40 +00:00
Gregory P. Smith 9d53457e59 Merge in release25-maint r60793:
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.
2008-06-11 07:41:16 +00:00
Gregory P. Smith dd96db63f6 This reverts r63675 based on the discussion in this thread:
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.
2008-06-09 04:58:54 +00:00
Christian Heimes 593daf545b Renamed PyString to PyBytes 2008-05-26 12:51:38 +00:00
Christian Heimes e93237dfcc #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available. 2007-12-19 02:37:44 +00:00
Martin v. Löwis 6819210b9e PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
2007-07-21 06:55:02 +00:00
Neal Norwitz c6a989ac3a Fix problems found by Coverity.
longobject.c: also fix an ssize_t problem
  <a> could have been NULL, so hoist the size calc to not use <a>.

_ssl.c: under fail: self is DECREF'd, but it would have been NULL.

_elementtree.c: delete self if there was an error.

_csv.c: I'm not sure if lineterminator could have been anything other than
a string.  However, other string method calls are checked, so check this
one too.
2006-05-10 06:57:58 +00:00
Thomas Wouters c6e55068ca Use Py_VISIT in all tp_traverse methods, instead of traversing manually or
using a custom, nearly-identical macro. This probably changes how some of
these functions are compiled, which may result in fractionally slower (or
faster) execution. Considering the nature of traversal, visiting much of the
address space in unpredictable patterns, I'd argue the code readability and
maintainability is well worth it ;P
2006-04-15 21:47:09 +00:00
Thomas Wouters 73536e039b Remove partial change (don't edit, commit and think at the same time :P) 2006-04-15 17:36:42 +00:00
Thomas Wouters 2742c5ed63 Re-instate backward compatibility by defining Py_CLEAR if it isn't
available.
2006-04-15 17:33:14 +00:00
Thomas Wouters edf17d8798 Use Py_CLEAR instead of in-place DECREF/XDECREF or custom macros, for
tp_clear methods.
2006-04-15 17:28:34 +00:00
Fredrik Lundh 4aaaa49bac docstring tweak 2006-04-04 16:51:13 +00:00
Martin v. Löwis 02cbf4ae4b More unconsting. 2006-02-27 17:20:04 +00:00
Jeremy Hylton af68c874a6 Add const to several API functions that take char *.
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 *.
2005-12-10 18:50:16 +00:00
Skip Montanaro 32c5d424fd Michael Hudson pointed out that the Dialect_Type object isn't INCREF'd. Why
this worked is a bit mystical.  Perhaps it never gets freed because the
object just happens never to be DECREF'd (but that seems unlikely).
2005-06-15 13:35:08 +00:00
Skip Montanaro d60fbd469e Leak fix from Michael Hudson. Fix memory leak when dialect doesn't
validate.  Closes 1220242.
2005-06-15 01:33:30 +00:00
Andrew McNamara f69d94f6c0 Moved reader \r and \n processing from the iterator to the state machine -
this allows for better handling of newline characters in quoted fields (and
hopefully resolves Bug 967934).
2005-01-13 11:30:54 +00:00
Andrew McNamara 5cfd83748a Improve wording of parser error message. 2005-01-12 11:39:50 +00:00
Andrew McNamara 7f2053eff3 Add counting of source iterator lines to the reader object - handy for
user error messages (otherwise difficult to do without instrumenting
the source).
2005-01-12 11:17:16 +00:00
Andrew McNamara 0f0599ddc1 When quoting=QUOTE_NONNUMERIC, the reader now casts unquoted fields
to floats.
2005-01-12 09:45:18 +00:00
Andrew McNamara 5d45a8dc22 Fix logic problem in quoting=csv.QUOTE_ALL, quotechar=None check, add test. 2005-01-12 08:16:17 +00:00
Andrew McNamara c89f284df8 When using QUOTE_NONNUMERIC, we now test for "numericness" with
PyNumber_Check, rather than trying to convert to a float.  Reimplemented
writer - now raises exceptions when it sees a quotechar but neither
doublequote or escapechar are set. Doublequote results are now more
consistent (eg, single quote should generate """", rather than "",
which is ambiguous).
2005-01-12 07:44:42 +00:00
Andrew McNamara 31d8896ee2 Rename csv.set_field_limit to csv.field_size_limit (since it both sets and
gets).
2005-01-12 03:45:10 +00:00
Andrew McNamara cf0fd5ab29 Add belt and braces check of PyString_AsString return. 2005-01-12 01:16:35 +00:00
Andrew McNamara e4d05c4f93 Set an upper limit on the size of the field buffer, raise an exception
when this limit is reached. Limit defaults to 128k, and is changed
by module set_field_limit() method. Previously, an unmatched quote
character could result in the entire file being read into the field
buffer, potentially exhausting virtual memory.
2005-01-11 07:32:02 +00:00
Andrew McNamara 29bf4e44f6 Now that internal dialect type is immutable, and the dialect registry
only contains instances of the dialect type, we can refer directly to the
dialect instances rather than creating new ones. In other words, if the
dialect comes from the registry, and we apply no further modifications,
the reader/writer can use the dialect object directly.
2005-01-11 04:49:53 +00:00
Andrew McNamara 8c94b42f31 No longer attempt to instantiate python classes describing dialects. This
was done because we were previously performing validation of the dialect
from python, but this is now down within the C module. Also, the method
we were using to detect classes did not work with new-style classes.
2005-01-11 02:18:36 +00:00
Andrew McNamara 86625972a1 Allow dialect-describing keywords to be supplied to register_dialect,
record objects of internal dialect type, rather than instances of
python objects.
2005-01-11 01:28:33 +00:00
Andrew McNamara 91b97463cd Factor out the code for making a dialect instance. 2005-01-11 01:07:23 +00:00
Andrew McNamara dbce2618b1 Only set error string when dict lookup found no matching key (was setting
it for all failures, potentially masking other exceptions).
2005-01-10 23:17:35 +00:00
Andrew McNamara a8292636c6 When parsing args that return a single character, treat null string the
same as None.
2005-01-10 12:25:11 +00:00
Andrew McNamara 37d2bdfa76 Where a string is desired, test for PyBaseString_Type derived type,
rather than using PyString_Check/PyUnicode_Check.
2005-01-10 12:22:48 +00:00
Andrew McNamara 77ead87f30 Add missing PyObject_GC_Track and PyObject_GC_UnTrack calls to csv reader and
writer objects (other GC infrastructure already in place).
2005-01-10 02:09:41 +00:00
Andrew McNamara 36a7691c2d Fix parsing of csv files with escapes (escape character previously would be
left in stream).
2005-01-10 01:04:40 +00:00
Andrew McNamara dd3e6cb213 Fix to use PEP7 brace style. 2005-01-07 06:46:50 +00:00
Andrew McNamara 1196cf185c Improved the implementation of the internal "dialect" type. The new
implementation features better error reporting, and better compliance
with the PEP.
2005-01-07 04:42:45 +00:00
Andrew McNamara 575a00b575 Delete Reader_getiter and replace with PyObject_SelfIter. 2005-01-06 02:25:41 +00:00
Johannes Gijsbers 8d3b9dd09c Quote \r\n correctly, remove random indentation (patch #1009384). Thanks
Cherniavsky Beni!
2004-08-15 12:23:10 +00:00
Raymond Hettinger 1761a7cc8b Use PyArg_UnpackTuple() where possible. 2004-06-20 04:23:19 +00:00
Skip Montanaro 148eb6a6b6 doc nit 2003-12-02 18:57:47 +00:00
Andrew McNamara dcfb38c21b Fix potential leaks identified by Neal Norwitz. 2003-06-09 05:59:23 +00:00
Jeremy Hylton 42a8aedb29 Make readers and writers participate in garbage collection.
Fix memory leak in dialect_init().
2003-04-14 02:20:55 +00:00
Tim Peters 38fc837fa9 Must declare vrbls at the tops of blocks in C89 (wouldn't compile). 2003-04-13 03:25:15 +00:00
Skip Montanaro 7b01a83488 use PyModule_Add{Int,String}Constant() where appropriate
(thanks to Neal Norwitz for the code review, BTW)
2003-04-12 19:23:46 +00:00
Skip Montanaro 577c7a763d tighten up string checks
make csv_{get,unregister}_dialect METH_O functions to avoid PyArg_ParseTuple
2003-04-12 19:17:14 +00:00
Skip Montanaro 860fc0b1d5 add writerows docstring
conditionally exclude Unicode functions
2003-04-12 18:57:52 +00:00
Skip Montanaro 98f16e0074 typo 2003-04-11 23:10:13 +00:00
Skip Montanaro dfa35fa3b6 typo 2003-04-11 21:40:01 +00:00
Skip Montanaro 3bc093b717 zap commented out bit of code 2003-04-11 19:33:55 +00:00
Skip Montanaro a16b21fb0a add comment about 2.2 compatibility
dump empty TODO comment
2003-03-23 14:32:54 +00:00