[Pyshapelib-commits] r2902 - trunk/pyshapelib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Dec 28 15:47:20 CET 2011
Author: bramz
Date: 2011-12-28 15:47:20 +0100 (Wed, 28 Dec 2011)
New Revision: 2902
Modified:
trunk/pyshapelib/dbflibmodule.c
Log:
Changing return_unicode default from False to True.
Modified: trunk/pyshapelib/dbflibmodule.c
===================================================================
--- trunk/pyshapelib/dbflibmodule.c 2011-12-26 23:12:02 UTC (rev 2901)
+++ trunk/pyshapelib/dbflibmodule.c 2011-12-28 14:47:20 UTC (rev 2902)
@@ -33,7 +33,7 @@
self = (DBFFileObject*) type->tp_alloc(type, 0);
self->handle = NULL;
self->codec = NULL;
- self->return_unicode = 0;
+ self->return_unicode = 1;
return (PyObject*) self;
}
@@ -119,7 +119,7 @@
SAHooks hooks;
char* file = NULL;
char* mode = "rb";
- PyObject* return_unicode = 0;
+ PyObject* return_unicode = NULL;
PyObject* codecs_map = NULL;
#if HAVE_CODE_PAGE
static char *kwlist[] = {"name", "mode", "return_unicode", "codecs_map", NULL};
@@ -149,7 +149,13 @@
}
PyMem_Free(file);
- self->return_unicode = return_unicode && PyObject_IsTrue(return_unicode);
+ self->return_unicode = return_unicode ? PyObject_IsTrue(return_unicode) : 1;
+ if (self->return_unicode < 0)
+ {
+ DBFClose(self->handle);
+ self->handle = NULL;
+ return -1;
+ }
if (dbffile_init_codec(self, codecs_map) != 0)
{
@@ -669,7 +675,7 @@
"- decimals: the number of decimal digits" },
#if HAVE_DELETE_FIELD
{"delete_field", (PyCFunction)dbffile_delete_field, METH_NOARGS,
- "delete_field(field_index) -> None"
+ "delete_field(field_index) -> None\n\n"
"removes an entire column"},
#endif
{"read_attribute", (PyCFunction)dbffile_read_attribute, METH_VARARGS,
@@ -749,9 +755,9 @@
if (!handle)
{
- PyErr_SetFromErrnoWithFilename(PyExc_IOError, file);
- PyMem_Free(file);
- return NULL;
+ PyErr_SetFromErrnoWithFilename(PyExc_IOError, file);
+ PyMem_Free(file);
+ return NULL;
}
PyMem_Free(file);
@@ -763,8 +769,14 @@
}
result->handle = handle;
- result->return_unicode = return_unicode && PyObject_IsTrue(return_unicode);
+ result->return_unicode = return_unicode ? PyObject_IsTrue(return_unicode) : 1;
result->codec = NULL;
+
+ if (result->return_unicode < 0)
+ {
+ dbffile_dealloc(result);
+ return NULL;
+ }
if (dbffile_init_codec(result, codecs_map) != 0)
{
@@ -781,16 +793,16 @@
{
{"open", (PyCFunction)dbflib_open, METH_VARARGS | METH_KEYWORDS,
#if HAVE_CODE_PAGE
- "open(name [, mode [, return_unicode [, codecs_map]]]) -> DBFFile\n\n"
+ "open(name, mode='rb', return_unicode=True, codecs_map=None) -> DBFFile\n\n"
#else
- "open(name [, mode [, return_unicode]]) -> DBFFile\n\n"
+ "open(name, mode='rb', return_unicode=True) -> DBFFile\n\n"
#endif
"opens a DBFFile" },
{"create", (PyCFunction)dbflib_create, METH_VARARGS | METH_KEYWORDS,
#if HAVE_CODE_PAGE
- "create(name [, code_page [, return_unicode [, codecs_map]]]) -> DBFFile\n\n"
+ "create(name, code_page='" DEFAULT_CODE_PAGE "', return_unicode=True, codecs_map=None) -> DBFFile\n\n"
#else
- "create(name [, return_unicode]) -> DBFFile\n\n"
+ "create(name, return_unicode=True) -> DBFFile\n\n"
#endif
"create a DBFFile " },
{NULL}
More information about the Pyshapelib-commits
mailing list