[fix] ListItem.setInfo (or actually anything that takes a string via python) can...
authorJim Carroll <thecarrolls@jiminger.com>
Sun, 29 Dec 2013 14:59:35 +0000 (09:59 -0500)
committerJim Carroll <thecarrolls@jiminger.com>
Sun, 29 Dec 2013 14:59:35 +0000 (09:59 -0500)
xbmc/interfaces/python/swig.cpp
xbmc/interfaces/python/swig.h

index 76ee9b5..8808f1e 100644 (file)
@@ -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?
index e8bd15d..d2bfdd2 100644 (file)
 
 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);