Skip to content

Commit f726dc4

Browse files
committed
Don't mess with string size if we don't care.
1 parent a791ce3 commit f726dc4

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

pdal/plang/Environment.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,7 @@ std::string readPythonString(PyObject* dict, const std::string& key)
9292

9393
PyObject* r = PyObject_Str(o);
9494
if (r)
95-
{
96-
Py_ssize_t size;
97-
s = PyUnicode_AsUTF8AndSize(r, &size);
98-
}
95+
s = PyUnicode_AsUTF8AndSize(r, NULL);
9996

10097
return s;
10198
}
@@ -222,9 +219,9 @@ std::string getTraceback()
222219
PyObject* r = PyObject_Repr(l);
223220
if (!r)
224221
throw pdal::pdal_error("unable to get repr in getTraceback");
225-
Py_ssize_t size;
226-
const char *d = PyUnicode_AsUTF8AndSize(r, &size);
227-
mssg << d;
222+
const char *d = PyUnicode_AsUTF8AndSize(r, NULL);
223+
if (d)
224+
mssg << d;
228225
}
229226

230227
// clean up
@@ -236,9 +233,9 @@ std::string getTraceback()
236233
PyObject* r = PyObject_Repr(value);
237234
if (!r)
238235
throw pdal::pdal_error("couldn't make string representation of traceback value");
239-
Py_ssize_t size;
240-
const char *d = PyUnicode_AsUTF8AndSize(r, &size);
241-
mssg << d;
236+
const char *d = PyUnicode_AsUTF8AndSize(r, NULL);
237+
if (d)
238+
mssg << d;
242239
}
243240
else
244241
mssg << "unknown error that we are unable to get a traceback for."

0 commit comments

Comments
 (0)