aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/interfaces/python/swig.cpp9
-rw-r--r--xbmc/interfaces/python/swig.h10
2 files changed, 19 insertions, 0 deletions
diff --git a/xbmc/interfaces/python/swig.cpp b/xbmc/interfaces/python/swig.cpp
index 76ee9b5cee..8808f1e5e4 100644
--- a/xbmc/interfaces/python/swig.cpp
+++ b/xbmc/interfaces/python/swig.cpp
@@ -21,6 +21,7 @@
#include "LanguageHook.h"
#include "swig.h"
#include "utils/StringUtils.h"
+#include "interfaces/legacy/AddonString.h"
#include <string>
@@ -46,6 +47,14 @@ namespace PythonBindings
void PyXBMCGetUnicodeString(std::string& buf, PyObject* pObject, bool coerceToString,
const char* argumentName, const char* methodname) throw (XBMCAddon::WrongTypeException)
{
+ // It's okay for a string to be "None". In this case the buf returned
+ // will be the emptyString.
+ if (pObject == Py_None)
+ {
+ buf = XBMCAddon::emptyString;
+ return;
+ }
+
// TODO: UTF-8: Does python use UTF-16?
// Do we need to convert from the string charset to UTF-8
// for non-unicode data?
diff --git a/xbmc/interfaces/python/swig.h b/xbmc/interfaces/python/swig.h
index e8bd15d267..d2bfdd2cdc 100644
--- a/xbmc/interfaces/python/swig.h
+++ b/xbmc/interfaces/python/swig.h
@@ -33,6 +33,16 @@
namespace PythonBindings
{
+ /**
+ * This call will convert the python object passed to a string. The object
+ * passed must be a python str or unicode object unless coerceToString is
+ * true. If coerceToString is true then the type must be castable to a string
+ * using the python call str(pObject).
+ *
+ * This method will handle a 'None' that's passed in. If 'None' is passed then
+ * the resulting buf will contain the value of XBMCAddon::emptyString (which
+ * is simply a std::string instantiated with the default constructor.
+ */
void PyXBMCGetUnicodeString(std::string& buf, PyObject* pObject, bool coerceToString = false,
const char* pos = "unknown",
const char* methodname = "unknown") throw (XBMCAddon::WrongTypeException);