[Thuban-commits] r2749 - branches/WIP-pyshapelib-bramz/libraries/pyshapelib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Mar 22 20:03:27 CET 2007


Author: bramz
Date: 2007-03-22 20:03:27 +0100 (Thu, 22 Mar 2007)
New Revision: 2749

Modified:
   branches/WIP-pyshapelib-bramz/libraries/pyshapelib/ChangeLog
   branches/WIP-pyshapelib-bramz/libraries/pyshapelib/dbflibmodule.c
   branches/WIP-pyshapelib-bramz/libraries/pyshapelib/shapelibmodule.c
Log:
in __init__ of ShapeFile and DBFFile, throw proper IOError if opening of file failed.

Modified: branches/WIP-pyshapelib-bramz/libraries/pyshapelib/ChangeLog
===================================================================
--- branches/WIP-pyshapelib-bramz/libraries/pyshapelib/ChangeLog	2007-03-20 23:18:34 UTC (rev 2748)
+++ branches/WIP-pyshapelib-bramz/libraries/pyshapelib/ChangeLog	2007-03-22 19:03:27 UTC (rev 2749)
@@ -1,3 +1,8 @@
+2007-03-22	Bram de Greve <bram.degreve at intec.ugent.be>
+
+	* shapelibmodule.c, dbflibmodule.c: in __init__ of ShapeFile and DBFFile,
+	throw proper IOError if opening of file failed.
+
 2007-03-21	Bram de Greve <bram.degreve at intec.ugent.be>
 
 	* shptreemodule.c: restoring something that shouldn't have been committed.

Modified: branches/WIP-pyshapelib-bramz/libraries/pyshapelib/dbflibmodule.c
===================================================================
--- branches/WIP-pyshapelib-bramz/libraries/pyshapelib/dbflibmodule.c	2007-03-20 23:18:34 UTC (rev 2748)
+++ branches/WIP-pyshapelib-bramz/libraries/pyshapelib/dbflibmodule.c	2007-03-22 19:03:27 UTC (rev 2749)
@@ -42,9 +42,13 @@
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "et|s:__init__", kwlist, 
 		Py_FileSystemDefaultEncoding, &file, &mode)) return -1;
 	
-	self->handle = DBFOpen(file, mode);
+	self->handle = DBFOpen(file, mode);	
+	if (!self->handle)
+	{
+		PyErr_SetFromErrnoWithFilename(PyExc_IOError, file);
+	}
+
 	PyMem_Free(file);
-	
 	return self->handle ? 0 : -1;
 }
 

Modified: branches/WIP-pyshapelib-bramz/libraries/pyshapelib/shapelibmodule.c
===================================================================
--- branches/WIP-pyshapelib-bramz/libraries/pyshapelib/shapelibmodule.c	2007-03-20 23:18:34 UTC (rev 2748)
+++ branches/WIP-pyshapelib-bramz/libraries/pyshapelib/shapelibmodule.c	2007-03-22 19:03:27 UTC (rev 2749)
@@ -554,8 +554,12 @@
 		Py_FileSystemDefaultEncoding, &file, &mode)) return -1;
 	
 	self->handle = SHPOpen(file, mode);
+	if (!self->handle)
+	{
+		PyErr_SetFromErrnoWithFilename(PyExc_IOError, file);
+	}
+
 	PyMem_Free(file);
-	
 	return self->handle ? 0 : -1;
 }
 



More information about the Thuban-commits mailing list