summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/CHANGES5
-rw-r--r--py/modules/IcePy/.depend2
-rw-r--r--py/modules/IcePy/ObjectAdapter.cpp52
-rw-r--r--py/modules/IcePy/Operation.cpp13
-rw-r--r--py/modules/IcePy/Types.cpp49
-rw-r--r--py/modules/IcePy/Types.h23
-rw-r--r--py/modules/IcePy/Util.cpp11
-rw-r--r--py/modules/IcePy/Util.h7
-rw-r--r--py/test/Ice/exceptions/AllTests.py64
-rw-r--r--py/test/Ice/servantLocator/AllTests.py87
-rw-r--r--py/test/Ice/servantLocator/Test.ice9
-rw-r--r--py/test/Ice/servantLocator/TestAMD.ice9
-rw-r--r--py/test/Ice/servantLocator/TestAMDI.py45
-rw-r--r--py/test/Ice/servantLocator/TestI.py43
14 files changed, 314 insertions, 105 deletions
diff --git a/py/CHANGES b/py/CHANGES
index 4d6f439b6fa..087f5667a96 100644
--- a/py/CHANGES
+++ b/py/CHANGES
@@ -1,13 +1,16 @@
Changes since version 3.2.X (binary incompatible)
-------------------------------------------------
+- Changed servant locators so both locate() and finished() can
+ throw user exceptions. (See the manual for details.)
+
- Fixed a bug where returning an AMD servant from a ServantLocator
would cause a deadlock in the IcePy extension.
- Added support for blobjects.
- Fixed a code generation bug with slice2py where the proxy type
- for a python reserved word would be incorrectly named. For example,
+ for a Python reserved word would be incorrectly named. For example,
interface def would generate a proxy class named _defPrx, not the
correct class name defPrx.
diff --git a/py/modules/IcePy/.depend b/py/modules/IcePy/.depend
index 179c835a866..b9acb575b09 100644
--- a/py/modules/IcePy/.depend
+++ b/py/modules/IcePy/.depend
@@ -4,7 +4,7 @@ Current$(OBJEXT): Current.cpp ./Current.h ./Config.h ./Connection.h ./ObjectAdap
ImplicitContext$(OBJEXT): ImplicitContext.cpp ./ImplicitContext.h ./Config.h ./ObjectAdapter.h ./Proxy.h ./Util.h
Init$(OBJEXT): Init.cpp ./Communicator.h ./Config.h ./Connection.h ./Current.h ./ImplicitContext.h ./Logger.h ./Util.h ./ObjectAdapter.h ./Operation.h ./Properties.h ./Proxy.h ./Slice.h ./Types.h
Logger$(OBJEXT): Logger.cpp ./Logger.h ./Config.h ./Util.h
-ObjectAdapter$(OBJEXT): ObjectAdapter.cpp ./ObjectAdapter.h ./Config.h ./Communicator.h ./Current.h ./Operation.h ./Proxy.h ./Util.h
+ObjectAdapter$(OBJEXT): ObjectAdapter.cpp ./ObjectAdapter.h ./Config.h ./Communicator.h ./Current.h ./Operation.h ./Proxy.h ./Types.h ./Util.h
ObjectFactory$(OBJEXT): ObjectFactory.cpp ./ObjectFactory.h ./Config.h ./Types.h ./Util.h
Operation$(OBJEXT): Operation.cpp ./Operation.h ./Config.h ./Current.h ./Proxy.h ./Types.h ./Util.h
Properties$(OBJEXT): Properties.cpp ./Properties.h ./Config.h ./Util.h
diff --git a/py/modules/IcePy/ObjectAdapter.cpp b/py/modules/IcePy/ObjectAdapter.cpp
index 0416b6a3a89..b96820c3f1e 100644
--- a/py/modules/IcePy/ObjectAdapter.cpp
+++ b/py/modules/IcePy/ObjectAdapter.cpp
@@ -15,6 +15,7 @@
#include <Current.h>
#include <Operation.h>
#include <Proxy.h>
+#include <Types.h>
#include <Util.h>
#include <Ice/Communicator.h>
#include <Ice/LocalException.h>
@@ -120,7 +121,23 @@ IcePy::ServantLocatorWrapper::locate(const Ice::Current& current, Ice::LocalObje
PyObjectHandle res = PyObject_CallMethod(_locator, STRCAST("locate"), STRCAST("O"), c->current);
if(PyErr_Occurred())
{
- throwPythonException();
+ PyException ex; // Retrieve the exception before another Python API call clears it.
+
+ //
+ // A locator that calls sys.exit() will raise the SystemExit exception.
+ // This is normally caught by the interpreter, causing it to exit.
+ // However, we have no way to pass this exception to the interpreter,
+ // so we act on it directly.
+ //
+ ex.checkSystemExit();
+
+ PyObject* userExceptionType = lookupType("Ice.UserException");
+ if(PyObject_IsInstance(ex.ex.get(), userExceptionType))
+ {
+ throw ExceptionWriter(current.adapter->getCommunicator(), ex.ex);
+ }
+
+ ex.raise();
}
if(res.get() == Py_None)
@@ -168,7 +185,8 @@ IcePy::ServantLocatorWrapper::locate(const Ice::Current& current, Ice::LocalObje
}
void
-IcePy::ServantLocatorWrapper::finished(const Ice::Current&, const Ice::ObjectPtr&, const Ice::LocalObjectPtr& cookie)
+IcePy::ServantLocatorWrapper::finished(const Ice::Current& current, const Ice::ObjectPtr&,
+ const Ice::LocalObjectPtr& cookie)
{
AdoptThread adoptThread; // Ensure the current thread is able to call into Python.
@@ -182,7 +200,23 @@ IcePy::ServantLocatorWrapper::finished(const Ice::Current&, const Ice::ObjectPtr
servantObj.get(), c->cookie);
if(PyErr_Occurred())
{
- throwPythonException();
+ PyException ex; // Retrieve the exception before another Python API call clears it.
+
+ //
+ // A locator that calls sys.exit() will raise the SystemExit exception.
+ // This is normally caught by the interpreter, causing it to exit.
+ // However, we have no way to pass this exception to the interpreter,
+ // so we act on it directly.
+ //
+ ex.checkSystemExit();
+
+ PyObject* userExceptionType = lookupType("Ice.UserException");
+ if(PyObject_IsInstance(ex.ex.get(), userExceptionType))
+ {
+ throw ExceptionWriter(current.adapter->getCommunicator(), ex.ex);
+ }
+
+ ex.raise();
}
}
@@ -194,7 +228,17 @@ IcePy::ServantLocatorWrapper::deactivate(const string& category)
PyObjectHandle res = PyObject_CallMethod(_locator, STRCAST("deactivate"), STRCAST("s"), category.c_str());
if(PyErr_Occurred())
{
- throwPythonException();
+ PyException ex; // Retrieve the exception before another Python API call clears it.
+
+ //
+ // A locator that calls sys.exit() will raise the SystemExit exception.
+ // This is normally caught by the interpreter, causing it to exit.
+ // However, we have no way to pass this exception to the interpreter,
+ // so we act on it directly.
+ //
+ ex.checkSystemExit();
+
+ ex.raise();
}
Py_DECREF(_locator);
diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp
index b6ec94283b1..19ae001c952 100644
--- a/py/modules/IcePy/Operation.cpp
+++ b/py/modules/IcePy/Operation.cpp
@@ -1799,10 +1799,7 @@ IcePy::TypedUpcall::exception(PyException& ex)
// However, we have no way to pass this exception to the interpreter,
// so we act on it directly.
//
- if(PyObject_IsInstance(ex.ex.get(), PyExc_SystemExit))
- {
- handleSystemExit(ex.ex.get()); // Does not return.
- }
+ ex.checkSystemExit();
PyObject* userExceptionType = lookupType("Ice.UserException");
@@ -1822,6 +1819,9 @@ IcePy::TypedUpcall::exception(PyException& ex)
else
{
Ice::OutputStreamPtr os = Ice::createOutputStream(_communicator);
+
+ os->writeBool(info->usesClasses);
+
ObjectMap objectMap;
info->marshal(ex.ex.get(), os, &objectMap);
@@ -2058,10 +2058,7 @@ IcePy::BlobjectUpcall::exception(PyException& ex)
// However, we have no way to pass this exception to the interpreter,
// so we act on it directly.
//
- if(PyObject_IsInstance(ex.ex.get(), PyExc_SystemExit))
- {
- handleSystemExit(ex.ex.get()); // Does not return.
- }
+ ex.checkSystemExit();
ex.raise();
}
diff --git a/py/modules/IcePy/Types.cpp b/py/modules/IcePy/Types.cpp
index eff2703fec6..422e8a9358a 100644
--- a/py/modules/IcePy/Types.cpp
+++ b/py/modules/IcePy/Types.cpp
@@ -2308,8 +2308,6 @@ IcePy::ExceptionInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Objec
throw AbortMarshaling();
}
- os->writeBool(usesClasses);
-
ExceptionInfoPtr info = this;
while(info)
{
@@ -2418,6 +2416,53 @@ IcePy::ExceptionInfo::printMembers(PyObject* value, IceUtil::Output& out, PrintO
}
//
+// ExceptionWriter implementation.
+//
+IcePy::ExceptionWriter::ExceptionWriter(const Ice::CommunicatorPtr& communicator, const PyObjectHandle& ex) :
+ Ice::UserExceptionWriter(communicator), _ex(ex)
+{
+ PyObjectHandle iceType = PyObject_GetAttrString(ex.get(), STRCAST("ice_type"));
+ assert(iceType.get());
+ _info = ExceptionInfoPtr::dynamicCast(getException(iceType.get()));
+ assert(_info);
+}
+
+IcePy::ExceptionWriter::~ExceptionWriter() throw()
+{
+}
+
+void
+IcePy::ExceptionWriter::write(const Ice::OutputStreamPtr& os) const
+{
+ ObjectMap objectMap;
+ _info->marshal(_ex.get(), os, &objectMap);
+}
+
+bool
+IcePy::ExceptionWriter::usesClasses() const
+{
+ return _info->usesClasses;
+}
+
+string
+IcePy::ExceptionWriter::ice_name() const
+{
+ return _info->id;
+}
+
+Ice::Exception*
+IcePy::ExceptionWriter::ice_clone() const
+{
+ return new ExceptionWriter(*this);
+}
+
+void
+IcePy::ExceptionWriter::ice_throw() const
+{
+ throw *this;
+}
+
+//
// lookupClassInfo()
//
IcePy::ClassInfoPtr
diff --git a/py/modules/IcePy/Types.h b/py/modules/IcePy/Types.h
index 4decb6741ef..0194cb5db28 100644
--- a/py/modules/IcePy/Types.h
+++ b/py/modules/IcePy/Types.h
@@ -409,6 +409,29 @@ private:
};
typedef IceUtil::Handle<ObjectReader> ObjectReaderPtr;
+//
+// ExceptionWriter wraps a Python user exception for marshaling.
+//
+class ExceptionWriter : public Ice::UserExceptionWriter
+{
+public:
+
+ ExceptionWriter(const Ice::CommunicatorPtr&, const PyObjectHandle&);
+ ~ExceptionWriter() throw();
+
+ virtual void write(const Ice::OutputStreamPtr&) const;
+ virtual bool usesClasses() const;
+
+ virtual std::string ice_name() const;
+ virtual Ice::Exception* ice_clone() const;
+ virtual void ice_throw() const;
+
+private:
+
+ PyObjectHandle _ex;
+ ExceptionInfoPtr _info;
+};
+
ClassInfoPtr lookupClassInfo(const std::string&);
ExceptionInfoPtr lookupExceptionInfo(const std::string&);
diff --git a/py/modules/IcePy/Util.cpp b/py/modules/IcePy/Util.cpp
index edf92dc2c14..98f51a460e0 100644
--- a/py/modules/IcePy/Util.cpp
+++ b/py/modules/IcePy/Util.cpp
@@ -58,7 +58,7 @@ IcePy::PyObjectHandle::operator=(const PyObjectHandle& p)
}
PyObject*
-IcePy::PyObjectHandle::get()
+IcePy::PyObjectHandle::get() const
{
return _p;
}
@@ -153,6 +153,15 @@ IcePy::PyException::raise()
}
void
+IcePy::PyException::checkSystemExit()
+{
+ if(PyObject_IsInstance(ex.get(), PyExc_SystemExit))
+ {
+ handleSystemExit(ex.get()); // Does not return.
+ }
+}
+
+void
IcePy::PyException::raiseLocalException()
{
string typeName = getTypeName();
diff --git a/py/modules/IcePy/Util.h b/py/modules/IcePy/Util.h
index ea246c1f461..7e191ce81ca 100644
--- a/py/modules/IcePy/Util.h
+++ b/py/modules/IcePy/Util.h
@@ -61,7 +61,7 @@ public:
void operator=(PyObject*);
void operator=(const PyObjectHandle&);
- PyObject* get();
+ PyObject* get() const;
PyObject* release();
private:
@@ -91,6 +91,11 @@ public:
//
void raise();
+ //
+ // If the Python exception is SystemExit, act on it. May not return.
+ //
+ void checkSystemExit();
+
PyObjectHandle ex;
private:
diff --git a/py/test/Ice/exceptions/AllTests.py b/py/test/Ice/exceptions/AllTests.py
index e3c1c2c248e..41af433ae5a 100644
--- a/py/test/Ice/exceptions/AllTests.py
+++ b/py/test/Ice/exceptions/AllTests.py
@@ -288,7 +288,7 @@ class AMI_WrongOperation_noSuchOperationI(CallbackBase):
self.called()
def allTests(communicator):
- print "testing servant registration exceptions... ",
+ print "testing servant registration exceptions...",
communicator.getProperties().setProperty("TestAdapter1.Endpoints", "default")
adapter = communicator.createObjectAdapter("TestAdapter1")
obj = EmptyI()
@@ -309,7 +309,7 @@ def allTests(communicator):
adapter.deactivate()
print "ok"
- print "testing servant locator registrations exceptions... ",
+ print "testing servant locator registrations exceptions...",
communicator.getProperties().setProperty("TestAdapter2.Endpoints", "default")
adapter = communicator.createObjectAdapter("TestAdapter2")
loc = ServantLocatorI()
@@ -323,7 +323,7 @@ def allTests(communicator):
adapter.deactivate()
print "ok"
- print "testing object factory registration exception... ",
+ print "testing object factory registration exception...",
of = ObjectFactoryI()
communicator.addObjectFactory(of, "x")
try:
@@ -333,19 +333,19 @@ def allTests(communicator):
pass
print "ok"
- print "testing stringToProxy... ",
+ print "testing stringToProxy...",
ref = "thrower:default -p 12010 -t 10000"
base = communicator.stringToProxy(ref)
test(base)
print "ok"
- print "testing checked cast... ",
+ print "testing checked cast...",
thrower = Test.ThrowerPrx.checkedCast(base)
test(thrower)
test(thrower == base)
print "ok"
- print "catching exact types... ",
+ print "catching exact types...",
try:
thrower.throwAasA(1)
@@ -412,7 +412,7 @@ def allTests(communicator):
print "ok"
- print "catching base types... ",
+ print "catching base types...",
try:
thrower.throwBasB(1, 2)
@@ -449,7 +449,7 @@ def allTests(communicator):
print "ok"
- print "catching derived types... ",
+ print "catching derived types...",
try:
thrower.throwBasA(1, 2)
@@ -486,16 +486,12 @@ def allTests(communicator):
print "ok"
if thrower.supportsUndeclaredExceptions():
- print "catching unknown user exception... ",
+ print "catching unknown user exception...",
try:
thrower.throwUndeclaredA(1)
test(False)
except Ice.UnknownUserException:
- #
- # We get an unknown user exception without collocation
- # optimization.
- #
pass
except:
print sys.exc_info()
@@ -505,10 +501,6 @@ def allTests(communicator):
thrower.throwUndeclaredB(1, 2)
test(False)
except Ice.UnknownUserException:
- #
- # We get an unknown user exception without collocation
- # optimization.
- #
pass
except:
print sys.exc_info()
@@ -518,10 +510,6 @@ def allTests(communicator):
thrower.throwUndeclaredC(1, 2, 3)
test(False)
except Ice.UnknownUserException:
- #
- # We get an unknown user exception without
- # collocation optimization.
- #
pass
except:
print sys.exc_info()
@@ -529,7 +517,7 @@ def allTests(communicator):
print "ok"
- print "catching object not exist exception... ",
+ print "catching object not exist exception...",
id = communicator.stringToIdentity("does not exist")
try:
@@ -545,7 +533,7 @@ def allTests(communicator):
print "ok"
- print "catching facet not exist exception... ",
+ print "catching facet not exist exception...",
try:
thrower2 = Test.ThrowerPrx.uncheckedCast(thrower, "no such facet")
@@ -560,7 +548,7 @@ def allTests(communicator):
print "ok"
- print "catching operation not exist exception... ",
+ print "catching operation not exist exception...",
try:
thrower2 = Test.WrongOperationPrx.uncheckedCast(thrower)
@@ -574,16 +562,12 @@ def allTests(communicator):
print "ok"
- print "catching unknown local exception... ",
+ print "catching unknown local exception...",
try:
thrower.throwLocalException()
test(False)
except Ice.UnknownLocalException:
- #
- # We get an unknown local exception without collocation
- # optimization.
- #
pass
except:
print sys.exc_info()
@@ -591,16 +575,12 @@ def allTests(communicator):
print "ok"
- print "catching unknown non-Ice exception... ",
+ print "catching unknown non-Ice exception...",
try:
thrower.throwNonIceException()
test(False)
except Ice.UnknownException:
- #
- # We get an unknown exception without collocation
- # optimization.
- #
pass
except:
print sys.exc_info()
@@ -608,7 +588,7 @@ def allTests(communicator):
print "ok"
- print "catching exact types with AMI... ",
+ print "catching exact types with AMI...",
cb = AMI_Thrower_throwAasAI()
thrower.throwAasA_async(cb, 1)
@@ -642,7 +622,7 @@ def allTests(communicator):
print "ok"
- print "catching derived types... ",
+ print "catching derived types...",
cb = AMI_Thrower_throwBasAI()
thrower.throwBasA_async(cb, 1, 2)
@@ -659,7 +639,7 @@ def allTests(communicator):
print "ok"
if thrower.supportsUndeclaredExceptions():
- print "catching unknown user exception with AMI... ",
+ print "catching unknown user exception with AMI...",
cb = AMI_Thrower_throwUndeclaredAI()
thrower.throwUndeclaredA_async(cb, 1)
@@ -675,7 +655,7 @@ def allTests(communicator):
print "ok"
- print "catching object not exist exception with AMI... ",
+ print "catching object not exist exception with AMI...",
id = communicator.stringToIdentity("does not exist")
thrower2 = Test.ThrowerPrx.uncheckedCast(thrower.ice_identity(id))
@@ -685,7 +665,7 @@ def allTests(communicator):
print "ok"
- print "catching facet not exist exception with AMI... ",
+ print "catching facet not exist exception with AMI...",
thrower2 = Test.ThrowerPrx.uncheckedCast(thrower, "no such facet")
cb = AMI_Thrower_throwAasAFacetNotExistI()
@@ -694,7 +674,7 @@ def allTests(communicator):
print "ok"
- print "catching operation not exist exception with AMI... ",
+ print "catching operation not exist exception with AMI...",
cb = AMI_WrongOperation_noSuchOperationI()
thrower4 = Test.WrongOperationPrx.uncheckedCast(thrower)
@@ -703,7 +683,7 @@ def allTests(communicator):
print "ok"
- print "catching unknown local exception with AMI... ",
+ print "catching unknown local exception with AMI...",
cb = AMI_Thrower_throwLocalExceptionI()
thrower.throwLocalException_async(cb)
@@ -711,7 +691,7 @@ def allTests(communicator):
print "ok"
- print "catching unknown non-Ice exception with AMI... ",
+ print "catching unknown non-Ice exception with AMI...",
cb = AMI_Thrower_throwNonIceExceptionI()
thrower.throwNonIceException_async(cb)
diff --git a/py/test/Ice/servantLocator/AllTests.py b/py/test/Ice/servantLocator/AllTests.py
index fcc9c33342f..fb8434769bf 100644
--- a/py/test/Ice/servantLocator/AllTests.py
+++ b/py/test/Ice/servantLocator/AllTests.py
@@ -18,72 +18,117 @@ def testExceptions(obj, collocated):
try:
obj.requestFailedException()
- test(false)
+ test(False)
except Ice.ObjectNotExistException, ex:
if not collocated:
test(ex.id == obj.ice_getIdentity())
test(ex.facet == obj.ice_getFacet())
test(ex.operation == "requestFailedException")
+ except:
+ test(False)
try:
obj.unknownUserException()
- test(false)
+ test(False)
except Ice.UnknownUserException, ex:
test(ex.unknown == "reason")
pass
+ except:
+ test(False)
try:
obj.unknownLocalException()
- test(false)
+ test(False)
except Ice.UnknownLocalException, ex:
test(ex.unknown == "reason")
pass
try:
obj.unknownException()
- test(false)
+ test(False)
except Ice.UnknownException, ex:
test(ex.unknown == "reason")
pass
try:
obj.userException()
- test(false)
+ test(False)
except Ice.UnknownUserException, ex:
- #print ex.unknown
- test(not collocated)
- test(ex.unknown.find("Test.TestIntfUserException") >= 0)
- except Test.TestIntfUserException:
- test(collocated)
+ test(ex.unknown.find("Test::TestIntfUserException") >= 0)
+ except:
+ test(False)
try:
obj.localException()
- test(false)
+ test(False)
except Ice.UnknownLocalException, ex:
- #print ex.unknown
test(not collocated)
test(ex.unknown.find("Ice.SocketException") >= 0)
except SocketException:
test(collocated)
+ except:
+ test(False)
try:
obj.pythonException()
- test(false)
+ test(False)
except Ice.UnknownException, ex:
- #print ex.unknown
- test(not collocated)
test(ex.unknown.find("RuntimeError: message") >= 0)
- except RuntimeError:
- test(collocated)
+ except:
+ test(False)
+
+ try:
+ obj.unknownExceptionWithServantException()
+ test(False)
+ except Ice.UnknownException, ex:
+ test(ex.unknown == "reason")
+ except:
+ test(False)
+
+ try:
+ obj.impossibleException(False)
+ test(False)
+ except Ice.UnknownUserException:
+ # Operation doesn't throw, but locate() and finshed() throw TestIntfUserException.
+ pass
+ except:
+ test(False)
+
+ try:
+ obj.impossibleException(True)
+ test(False)
+ except Ice.UnknownUserException:
+ # Operation doesn't throw, but locate() and finshed() throw TestIntfUserException.
+ pass
+ except:
+ test(False)
+
+ try:
+ obj.intfUserException(False)
+ test(False)
+ except Test.TestImpossibleException:
+ # Operation doesn't throw, but locate() and finshed() throw TestIntfUserException.
+ pass
+ except:
+ test(False)
+
+ try:
+ obj.intfUserException(True)
+ test(False)
+ except Test.TestImpossibleException:
+ # Operation doesn't throw, but locate() and finshed() throw TestIntfUserException.
+ pass
+ except:
+ test(False)
def allTests(communicator, collocated):
- print "testing stringToProxy... ",
+ print "testing stringToProxy...",
sys.stdout.flush()
base = communicator.stringToProxy("asm:default -p 12010 -t 10000")
test(base)
print "ok"
- print "testing checked cast... ",
+ print "testing checked cast...",
sys.stdout.flush()
obj = Test.TestIntfPrx.checkedCast(base)
test(obj)
@@ -116,14 +161,14 @@ def allTests(communicator, collocated):
pass
print "ok"
- print "testing locate exceptions... ",
+ print "testing locate exceptions...",
sys.stdout.flush()
base = communicator.stringToProxy("category/locate:default -p 12010 -t 10000")
obj = Test.TestIntfPrx.checkedCast(base)
testExceptions(obj, collocated)
print "ok"
- print "testing finished exceptions... ",
+ print "testing finished exceptions...",
sys.stdout.flush()
base = communicator.stringToProxy("category/finished:default -p 12010 -t 10000")
obj = Test.TestIntfPrx.checkedCast(base)
diff --git a/py/test/Ice/servantLocator/Test.ice b/py/test/Ice/servantLocator/Test.ice
index a0ecf41df1d..b0157771ffd 100644
--- a/py/test/Ice/servantLocator/Test.ice
+++ b/py/test/Ice/servantLocator/Test.ice
@@ -17,6 +17,10 @@ exception TestIntfUserException
{
};
+exception TestImpossibleException
+{
+};
+
interface TestIntf
{
void requestFailedException();
@@ -27,6 +31,11 @@ interface TestIntf
void userException();
void pythonException();
+ void unknownExceptionWithServantException();
+
+ string impossibleException(bool throw) throws TestImpossibleException;
+ string intfUserException(bool throw) throws TestIntfUserException, TestImpossibleException;
+
void shutdown();
};
diff --git a/py/test/Ice/servantLocator/TestAMD.ice b/py/test/Ice/servantLocator/TestAMD.ice
index fa62d346ffe..14747d48c84 100644
--- a/py/test/Ice/servantLocator/TestAMD.ice
+++ b/py/test/Ice/servantLocator/TestAMD.ice
@@ -17,6 +17,10 @@ exception TestIntfUserException
{
};
+exception TestImpossibleException
+{
+};
+
["amd"] interface TestIntf
{
void requestFailedException();
@@ -27,6 +31,11 @@ exception TestIntfUserException
void userException();
void pythonException();
+ void unknownExceptionWithServantException();
+
+ string impossibleException(bool throw) throws TestImpossibleException;
+ string intfUserException(bool throw) throws TestIntfUserException, TestImpossibleException;
+
void shutdown();
};
diff --git a/py/test/Ice/servantLocator/TestAMDI.py b/py/test/Ice/servantLocator/TestAMDI.py
index b19211b0b57..189702a4225 100644
--- a/py/test/Ice/servantLocator/TestAMDI.py
+++ b/py/test/Ice/servantLocator/TestAMDI.py
@@ -38,6 +38,29 @@ class TestI(Test.TestIntf):
def pythonException_async(self, cb, current=None):
cb.ice_response()
+ def unknownExceptionWithServantException_async(self, cb, current=None):
+ cb.ice_exception(Ice.ObjectNotExistException())
+
+ def impossibleException_async(self, cb, throw, current=None):
+ if throw:
+ cb.ice_exception(Test.TestImpossibleException())
+ else:
+ #
+ # Return a value so we can be sure that the stream position
+ # is reset correctly if finished() throws.
+ #
+ cb.ice_response("Hello")
+
+ def intfUserException_async(self, cb, throw, current=None):
+ if throw:
+ cb.ice_exception(Test.TestIntfUserException())
+ else:
+ #
+ # Return a value so we can be sure that the stream position
+ # is reset correctly if finished() throws.
+ #
+ cb.ice_response("Hello")
+
def shutdown_async(self, cb, current=None):
current.adapter.deactivate()
cb.ice_response()
@@ -89,22 +112,20 @@ class ServantLocatorI(Ice.ServantLocator):
if current.operation == "requestFailedException":
raise Ice.ObjectNotExistException()
elif current.operation == "unknownUserException":
- ex = Ice.UnknownUserException()
- ex.unknown = "reason"
- raise ex
+ raise Ice.UnknownUserException("reason")
elif current.operation == "unknownLocalException":
- ex = Ice.UnknownLocalException()
- ex.unknown = "reason"
- raise ex
+ raise Ice.UnknownLocalException("reason")
elif current.operation == "unknownException":
- ex = Ice.UnknownException()
- ex.unknown = "reason"
- raise ex
+ raise Ice.UnknownException("reason")
elif current.operation == "userException":
raise Test.TestIntfUserException()
elif current.operation == "localException":
- ex = Ice.SocketException()
- ex.error = 0
- raise ex
+ raise Ice.SocketException(0)
elif current.operation == "pythonException":
raise RuntimeError("message")
+ elif current.operation == "unknownExceptionWithServantException":
+ raise Ice.UnknownException("reason")
+ elif current.operation == "impossibleException":
+ raise Test.TestIntfUserException() # Yes, it really is meant to be TestIntfUserException.
+ elif current.operation == "intfUserException":
+ raise Test.TestImpossibleException() # Yes, it really is meant to be TestImpossibleException.
diff --git a/py/test/Ice/servantLocator/TestI.py b/py/test/Ice/servantLocator/TestI.py
index b79c7e9b337..52b367308ea 100644
--- a/py/test/Ice/servantLocator/TestI.py
+++ b/py/test/Ice/servantLocator/TestI.py
@@ -38,6 +38,27 @@ class TestI(Test.TestIntf):
def pythonException(self, current=None):
pass
+ def unknownExceptionWithServantException(self, current=None):
+ raise Ice.ObjectNotExistException()
+
+ def impossibleException(self, throw, current=None):
+ if throw:
+ raise Test.TestImpossibleException()
+ #
+ # Return a value so we can be sure that the stream position
+ # is reset correctly if finished() throws.
+ #
+ return "Hello"
+
+ def intfUserException(self, throw, current=None):
+ if throw:
+ raise Test.TestIntfUserException()
+ #
+ # Return a value so we can be sure that the stream position
+ # is reset correctly if finished() throws.
+ #
+ return "Hello"
+
def shutdown(self, current=None):
current.adapter.deactivate()
@@ -88,22 +109,20 @@ class ServantLocatorI(Ice.ServantLocator):
if current.operation == "requestFailedException":
raise Ice.ObjectNotExistException()
elif current.operation == "unknownUserException":
- ex = Ice.UnknownUserException()
- ex.unknown = "reason"
- raise ex
+ raise Ice.UnknownUserException("reason")
elif current.operation == "unknownLocalException":
- ex = Ice.UnknownLocalException()
- ex.unknown = "reason"
- raise ex
+ raise Ice.UnknownLocalException("reason")
elif current.operation == "unknownException":
- ex = Ice.UnknownException()
- ex.unknown = "reason"
- raise ex
+ raise Ice.UnknownException("reason")
elif current.operation == "userException":
raise Test.TestIntfUserException()
elif current.operation == "localException":
- ex = Ice.SocketException()
- ex.error = 0
- raise ex
+ raise Ice.SocketException(0)
elif current.operation == "pythonException":
raise RuntimeError("message")
+ elif current.operation == "unknownExceptionWithServantException":
+ raise Ice.UnknownException("reason")
+ elif current.operation == "impossibleException":
+ raise Test.TestIntfUserException() # Yes, it really is meant to be TestIntfUserException.
+ elif current.operation == "intfUserException":
+ raise Test.TestImpossibleException() # Yes, it really is meant to be TestImpossibleException.