[Commits] (vajda) Fixed bug where exceptions raised in python code called from PyLucene would disappear.

commits at osafoundation.org commits at osafoundation.org
Tue Mar 30 17:40:36 PST 2004


Commit by: vajda
Modified files:
external/persistence/PyLucene/Makefile.dev 1.2 1.3
external/persistence/PyLucene/PyLucene.i 1.1 1.2
external/persistence/PyLucene/PyLucene_wrap.cxx 1.1 1.2

Log message:
Fixed bug where exceptions raised in python code called from PyLucene would disappear.


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/external/persistence/PyLucene/Makefile.dev.diff?r1=text&tr1=1.2&r2=text&tr2=1.3
http://cvs.osafoundation.org/index.cgi/external/persistence/PyLucene/PyLucene.i.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/external/persistence/PyLucene/PyLucene_wrap.cxx.diff?r1=text&tr1=1.1&r2=text&tr2=1.2

Index: external/persistence/PyLucene/Makefile.dev
diff -u external/persistence/PyLucene/Makefile.dev:1.2 external/persistence/PyLucene/Makefile.dev:1.3
--- external/persistence/PyLucene/Makefile.dev:1.2	Thu Mar 18 18:14:31 2004
+++ external/persistence/PyLucene/Makefile.dev	Tue Mar 30 17:40:05 2004
@@ -1,6 +1,9 @@
 
 # An OS X Makefile for development only
 
+VERSION=1.3-final
+DBVERSION=4.2.52
+
 ifeq ($(DEBUG),1)
 
 CCFLAGS = -O -g
@@ -9,8 +12,8 @@
 
 else
 
-CCFLAGS = -O2 -g
-LDFLAGS = -g
+CCFLAGS = -O2
+LDFLAGS = 
 mode = release
 
 endif
@@ -63,10 +66,10 @@
 	$(JCC) -C -d $(CLASSES) java/org/osafoundation/io/PythonReader.java
 	$(JCC) $(CCFLAGS) -c -o $(BINDIR)/reader.java.o java/org/osafoundation/io/PythonReader.java
 
-$(BINDIR)/reader.cpp.o: cpp/PythonReader.cpp $(BINDIR)/reader.java.o
+$(BINDIR)/reader.cpp.o: $(CLASSES)/org/osafoundation/io/PythonReader.h cpp/PythonReader.cpp $(BINDIR)/reader.java.o
 	$(JCC) -I$(PYTHON_INC) -I$(CLASSES) $(CCFLAGS) -c -o $(BINDIR)/reader.cpp.o cpp/PythonReader.cpp
 
-PyLucene_wrap.cxx: PyLucene.i $(BINDIR)/reader.java.o
+$(CLASSES)/org/osafoundation/io/PythonReader.h:
 	$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) com.sleepycat.db.DbEnv
 	$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) com.sleepycat.db.Db
 	$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) com.sleepycat.db.DbTxn
@@ -83,12 +86,14 @@
 	$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.search.IndexSearcher
 	$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.apache.lucene.queryParser.QueryParser
 	$(JCCH) -d $(CLASSES) --classpath=$(CLASSES) org.osafoundation.io.PythonReader
+
+PyLucene_wrap.cxx: PyLucene.i $(BINDIR)/reader.java.o
 	swig -modern -I$(BINDIR)/classes -c++ -python PyLucene.i
 
 $(BINDIR)/_PyLucene.so: $(OBJS) PyLucene_wrap.cxx
 	$(CXX) -shared -bundle -o $(BINDIR)/_PyLucene.so $(CCFLAGS) -I$(CLASSES) -I$(PYTHON_INC) -I/usr/local/BerkeleyDB.4.2/include PyLucene_wrap.cxx $(BINDIR)/db_const.o $(BINDIR)/db.o $(BINDIR)/store.o $(BINDIR)/lucene.o $(BINDIR)/reader.java.o $(BINDIR)/reader.cpp.o -lgcj -liconv -flat_namespace -multiply_defined suppress -undefined warning
 
-all: $(BINDIR)/_PyLucene.so $(BINDIR)/libdb_java-4.2.jnilib
+all: $(BINDIR)/_PyLucene.so $(BINDIR)/libdb_java-4.2.jnilib PyLucene_wrap.cxx
 	echo build of $(BINDIR)/_PyLucene.so complete
 
 install: $(BINDIR)/_PyLucene.so $(BINDIR)/libdb_java-4.2.jnilib

Index: external/persistence/PyLucene/PyLucene.i
diff -u external/persistence/PyLucene/PyLucene.i:1.1 external/persistence/PyLucene/PyLucene.i:1.2
--- external/persistence/PyLucene/PyLucene.i:1.1	Mon Mar 15 11:48:40 2004
+++ external/persistence/PyLucene/PyLucene.i	Tue Mar 30 17:40:05 2004
@@ -200,6 +200,8 @@
 
     try {
         $action
+        if (PyErr_Occurred())
+            return NULL;
     } catch (java::lang::Throwable *e) {
         java::io::StringWriter *buffer = new java::io::StringWriter();
 	java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);

Index: external/persistence/PyLucene/PyLucene_wrap.cxx
diff -u external/persistence/PyLucene/PyLucene_wrap.cxx:1.1 external/persistence/PyLucene/PyLucene_wrap.cxx:1.2
--- external/persistence/PyLucene/PyLucene_wrap.cxx:1.1	Mon Mar 15 11:48:40 2004
+++ external/persistence/PyLucene/PyLucene_wrap.cxx	Tue Mar 30 17:40:05 2004
@@ -843,6 +843,8 @@
         try {
             result = (java::lang::Object *)new java::lang::Object();
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -879,6 +881,8 @@
         try {
             delete arg1;
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -930,6 +934,8 @@
         try {
             result = (void *)attachCurrentThread(arg1);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -966,6 +972,8 @@
         try {
             delete arg1;
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1047,6 +1055,8 @@
         try {
             result = (org::apache::lucene::store::db::DbDirectory *)new org::apache::lucene::store::db::DbDirectory(arg1,arg2,arg3,arg4);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1083,6 +1093,8 @@
         try {
             delete arg1;
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1124,6 +1136,8 @@
         try {
             result = (org::apache::lucene::analysis::Analyzer *)new org::apache::lucene::analysis::Analyzer();
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1160,6 +1174,8 @@
         try {
             delete arg1;
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1201,6 +1217,8 @@
         try {
             result = (org::apache::lucene::analysis::standard::StandardAnalyzer *)new org::apache::lucene::analysis::standard::StandardAnalyzer();
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1237,6 +1255,8 @@
         try {
             delete arg1;
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1309,6 +1329,8 @@
         try {
             result = (org::apache::lucene::document::Field *)new org::apache::lucene::document::Field(arg1,arg2,arg3,arg4,arg5);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1364,6 +1386,8 @@
         try {
             result = (org::apache::lucene::document::Field *)org::apache::lucene::document::Field::Text(arg1,arg2);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1414,6 +1438,8 @@
         try {
             result = (org::apache::lucene::document::Field *)org::apache::lucene::document::Field::UnIndexed(arg1,arg2);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1464,6 +1490,8 @@
         try {
             result = (org::apache::lucene::document::Field *)org::apache::lucene::document::Field::UnStored(arg1,arg2);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1500,6 +1528,8 @@
         try {
             delete arg1;
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1541,6 +1571,8 @@
         try {
             result = (org::apache::lucene::document::Document *)new org::apache::lucene::document::Document();
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1580,6 +1612,8 @@
         try {
             (arg1)->add(arg2);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1625,6 +1659,8 @@
         try {
             result = (arg1)->get(arg2);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1674,6 +1710,8 @@
         try {
             delete arg1;
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1726,6 +1764,8 @@
         try {
             result = (org::apache::lucene::index::IndexWriter *)new org::apache::lucene::index::IndexWriter(arg1,arg2,arg3);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1762,6 +1802,8 @@
         try {
             (arg1)->close();
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1801,6 +1843,8 @@
         try {
             (arg1)->addDocument(arg2);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -1837,6 +1881,8 @@
         try {
             (arg1)->optimize();
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2009,6 +2055,8 @@
         try {
             delete arg1;
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2053,6 +2101,8 @@
         try {
             (arg1)->setBoost(arg2);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2090,6 +2140,8 @@
         try {
             result = (jfloat)(arg1)->getBoost();
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2127,6 +2179,8 @@
         try {
             result = (arg1)->toString();
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2184,6 +2238,8 @@
         try {
             result = (jint)(arg1)->length();
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2222,6 +2278,8 @@
         try {
             result = (org::apache::lucene::document::Document *)(arg1)->doc(arg2);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2260,6 +2318,8 @@
         try {
             result = (jfloat)(arg1)->score(arg2);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2298,6 +2358,8 @@
         try {
             result = (jint)(arg1)->id(arg2);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2345,6 +2407,8 @@
         try {
             result = (org::apache::lucene::search::Hits *)(arg1)->search(arg2);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2389,6 +2453,8 @@
         try {
             result = (org::apache::lucene::search::IndexSearcher *)new org::apache::lucene::search::IndexSearcher(arg1);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2425,6 +2491,8 @@
         try {
             (arg1)->close();
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2461,6 +2529,8 @@
         try {
             delete arg1;
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);
@@ -2521,6 +2591,8 @@
         try {
             result = (org::apache::lucene::search::Query *)org::apache::lucene::queryParser::QueryParser::parse(arg1,arg2,arg3);
             
+            if (PyErr_Occurred())
+            return NULL;
         } catch (java::lang::Throwable *e) {
             java::io::StringWriter *buffer = new java::io::StringWriter();
             java::io::PrintWriter *writer = new java::io::PrintWriter(buffer);



More information about the Commits mailing list