NSPopupButton and adding value not in list triggers __repr__ instead of description cause unicode issues

Issue #116 new
Marc Van Olmen
created an issue


I just want start a thread on this, I haven't spend time in making a separate app to proof the bug exist.

But basically this is the behavior I'm seeing.

We have a nspopupbutton that is linked with bindings:

  • Content is a list of PythonObjects. path: myList
  • The values shown is myList.description
  • When I set the selected value to an object that is not in the list. For that particular value the function "description" is not called but the repr function is called. But that causes issues on 2.7 because it can't contain unicode characters. And for one our users did got triggered because of £ symbol in the string. So the exception that was triggered then broke the app.

I hope to find time to build a separate app to demonstrate the bug


Comments (5)

  1. Ronald Oussoren repo owner

    A possible workaround:


    mport sys

    That way the output of __repr__ can be converted to a unicode object (assuming that it returns a UTF-8 encoded string).

    BTW. Which version of PyObjC do you use? In 3.0 -[OC_PythonObject description] should use the "replace" error handler when converting a python str() value to unicode and that shouldn't raise an exception.

    That said, I don't think there is a unites for this yet.

  2. Log in to comment