Commit Graph

44 Commits

Author SHA1 Message Date
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
Tim Peters ef4b7ed42b Squash compiler wng about signed-vs-unsigned mismatch. 2003-03-21 01:35:28 +00:00
Skip Montanaro b4a0417e91 new CSV file processing module - see PEP 305 2003-03-20 23:29:12 +00:00