summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2015-08-26 10:50:03 +0200
committerBenoit Foucher <benoit@zeroc.com>2015-08-26 10:50:03 +0200
commite62dfd115fac182bb7818bca91972468f70ac67e (patch)
treeb7c79d4a559a9bd59eaa0043204fafec99de88d7 /python
parentminor reformatting of CHANGELOG-3.6.md (diff)
downloadice-e62dfd115fac182bb7818bca91972468f70ac67e.tar.bz2
ice-e62dfd115fac182bb7818bca91972468f70ac67e.tar.xz
ice-e62dfd115fac182bb7818bca91972468f70ac67e.zip
Fixed ICE-6725 - value demo python crash w/ python 2.7 on Windows
Diffstat (limited to 'python')
-rw-r--r--python/modules/IcePy/Types.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/python/modules/IcePy/Types.cpp b/python/modules/IcePy/Types.cpp
index ed737247264..ea749bad672 100644
--- a/python/modules/IcePy/Types.cpp
+++ b/python/modules/IcePy/Types.cpp
@@ -406,13 +406,23 @@ IcePy::SlicedDataUtil::setMember(PyObject* obj, const Ice::SlicedDataPtr& sliced
//
// bytes
//
-#if PY_VERSION_HEX >= 0x03000000
- PyObjectHandle bytes =
- PyBytes_FromStringAndSize(reinterpret_cast<const char*>(&(*p)->bytes[0]), (*p)->bytes.size());
-#else
- PyObjectHandle bytes =
- PyString_FromStringAndSize(reinterpret_cast<const char*>(&(*p)->bytes[0]), (*p)->bytes.size());
-#endif
+ PyObjectHandle bytes;
+ if((*p)->bytes.size() > 0)
+ {
+ #if PY_VERSION_HEX >= 0x03000000
+ bytes = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(&(*p)->bytes[0]), (*p)->bytes.size());
+ #else
+ bytes = PyString_FromStringAndSize(reinterpret_cast<const char*>(&(*p)->bytes[0]), (*p)->bytes.size());
+ #endif
+ }
+ else
+ {
+ #if PY_VERSION_HEX >= 0x03000000
+ bytes = PyBytes_FromStringAndSize(0, 0);
+ #else
+ bytes = PyString_FromStringAndSize(0, 0);
+ #endif
+ }
if(!bytes.get() || PyObject_SetAttrString(slice.get(), STRCAST("bytes"), bytes.get()) < 0)
{
assert(PyErr_Occurred());