diff options
author | Mark Spruiell <mes@zeroc.com> | 2009-10-27 13:20:39 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2009-10-27 13:20:39 -0700 |
commit | 370cfa6a7f7a3bb188dfb66bad09f3283a07aab8 (patch) | |
tree | 61b68c219c6c637f8621673d3b96bc8ad624c261 /py/modules/IcePy/Communicator.cpp | |
parent | bug 4333 - fixing TestUtil issue (diff) | |
download | ice-370cfa6a7f7a3bb188dfb66bad09f3283a07aab8.tar.bz2 ice-370cfa6a7f7a3bb188dfb66bad09f3283a07aab8.tar.xz ice-370cfa6a7f7a3bb188dfb66bad09f3283a07aab8.zip |
bug 4335 - Python segfault
Diffstat (limited to 'py/modules/IcePy/Communicator.cpp')
-rw-r--r-- | py/modules/IcePy/Communicator.cpp | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/py/modules/IcePy/Communicator.cpp b/py/modules/IcePy/Communicator.cpp index 72f33ff56b5..f3cf4f3d4f7 100644 --- a/py/modules/IcePy/Communicator.cpp +++ b/py/modules/IcePy/Communicator.cpp @@ -476,12 +476,17 @@ static PyObject* communicatorProxyToString(CommunicatorObject* self, PyObject* args) { PyObject* obj; - if(!PyArg_ParseTuple(args, STRCAST("O!"), &ProxyType, &obj)) + if(!PyArg_ParseTuple(args, STRCAST("O"), &obj)) + { + return 0; + } + + Ice::ObjectPrx proxy; + if(!getProxyArg(obj, "proxyToString", "obj", proxy)) { return 0; } - Ice::ObjectPrx proxy = getProxy(obj); string str; assert(self->communicator); @@ -542,9 +547,13 @@ extern "C" static PyObject* communicatorProxyToProperty(CommunicatorObject* self, PyObject* args) { + // + // We don't want to accept None here, so we can specify ProxyType and force + // the caller to supply a proxy object. + // PyObject* proxyObj; PyObject* strObj; - if(!PyArg_ParseTuple(args, STRCAST("OO"), &proxyObj, &strObj)) + if(!PyArg_ParseTuple(args, STRCAST("O!O"), &ProxyType, &proxyObj, &strObj)) { return 0; } @@ -1071,8 +1080,8 @@ static PyObject* communicatorCreateObjectAdapterWithRouter(CommunicatorObject* self, PyObject* args) { PyObject* nameObj; - PyObject* proxy; - if(!PyArg_ParseTuple(args, STRCAST("OO"), &nameObj, &proxy)) + PyObject* p; + if(!PyArg_ParseTuple(args, STRCAST("OO"), &nameObj, &p)) { return 0; } @@ -1083,25 +1092,19 @@ communicatorCreateObjectAdapterWithRouter(CommunicatorObject* self, PyObject* ar return 0; } - PyObject* routerProxyType = lookupType("Ice.RouterPrx"); - assert(routerProxyType); - Ice::RouterPrx router; - if(PyObject_IsInstance(proxy, routerProxyType)) - { - router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); - } - else if(proxy != Py_None) + Ice::ObjectPrx proxy; + if(!getProxyArg(p, "createObjectAdapterWithRouter", "rtr", proxy, "Ice.RouterPrx")) { - PyErr_Format(PyExc_ValueError, STRCAST("createObjectAdapterWithRouter requires None or Ice.RouterPrx")); return 0; } - AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. + Ice::RouterPrx router = Ice::RouterPrx::uncheckedCast(proxy); assert(self->communicator); Ice::ObjectAdapterPtr adapter; try { + AllowThreads allowThreads; // Release Python's global interpreter lock to avoid a potential deadlock. adapter = (*self->communicator)->createObjectAdapterWithRouter(name, router); } catch(const Ice::Exception& ex) @@ -1160,25 +1163,20 @@ extern "C" static PyObject* communicatorSetDefaultRouter(CommunicatorObject* self, PyObject* args) { - PyObject* proxy; - if(!PyArg_ParseTuple(args, STRCAST("O"), &proxy)) + PyObject* p; + if(!PyArg_ParseTuple(args, STRCAST("O"), &p)) { return 0; } - PyObject* routerProxyType = lookupType("Ice.RouterPrx"); - assert(routerProxyType); - Ice::RouterPrx router; - if(PyObject_IsInstance(proxy, routerProxyType)) - { - router = Ice::RouterPrx::uncheckedCast(getProxy(proxy)); - } - else if(proxy != Py_None) + Ice::ObjectPrx proxy; + if(!getProxyArg(p, "setDefaultRouter", "rtr", proxy, "Ice.RouterPrx")) { - PyErr_Format(PyExc_ValueError, STRCAST("setDefaultRouter requires None or Ice.RouterPrx")); return 0; } + Ice::RouterPrx router = Ice::RouterPrx::uncheckedCast(proxy); + assert(self->communicator); try { @@ -1229,25 +1227,20 @@ extern "C" static PyObject* communicatorSetDefaultLocator(CommunicatorObject* self, PyObject* args) { - PyObject* proxy; - if(!PyArg_ParseTuple(args, STRCAST("O"), &proxy)) + PyObject* p; + if(!PyArg_ParseTuple(args, STRCAST("O"), &p)) { return 0; } - PyObject* locatorProxyType = lookupType("Ice.LocatorPrx"); - assert(locatorProxyType); - Ice::LocatorPrx locator; - if(PyObject_IsInstance(proxy, locatorProxyType)) - { - locator = Ice::LocatorPrx::uncheckedCast(getProxy(proxy)); - } - else if(proxy != Py_None) + Ice::ObjectPrx proxy; + if(!getProxyArg(p, "setDefaultLocator", "loc", proxy, "Ice.LocatorPrx")) { - PyErr_Format(PyExc_ValueError, STRCAST("setDefaultLocator requires None or Ice.LocatorPrx")); return 0; } + Ice::LocatorPrx locator = Ice::LocatorPrx::uncheckedCast(proxy); + assert(self->communicator); try { |