jaredks / rumps

Ridiculously Uncomplicated macOS Python Statusbar apps
BSD 3-Clause "New" or "Revised" License
3.06k stars 177 forks source link

Notification data passing error #126

Closed rejsmont closed 4 years ago

rejsmont commented 4 years ago

Hi,

passing data to the notification center does not work. The sample app:

import rumps

@rumps.notifications
def notification_center(info):
    print(info)

class TestApp(rumps.App):
    @rumps.clicked('Test Notification')
    def testing(self, sender):
        test = 'test string'
        rumps.notification("Foo", "Bar", "Baz", data={'foo': 'bar'}, action_button='Action', other_button='Dismiss')

if __name__ == "__main__":
    app = TestApp('Test')
    app.run()

throws the following exception:

2019-11-29 18:03:11.936 Python[74881:1454881] -[OC_BuiltinPythonData fastestEncoding]: unrecognized selector sent to instance 0x7fa05ed3e910
/Users/rejsmont/src/rumps_test/venv/lib/python3.7/site-packages/rumps/rumps.py:185: UninitializedDeallocWarning: leaking an uninitialized object of type NSPlaceholderString
  ns_string = NSString.alloc().initWithString_(dumped)

Python version:

# python -V
Python 3.7.5

PIP packages installed:

Package                Version
---------------------- -------
Cython                 0.29.14
pathtools              0.1.2
pip                    19.3.1
pyobjc-core            6.1
pyobjc-framework-Cocoa 6.1
PyYAML                 5.1.2
rumps                  0.3.0
setuptools             42.0.0
jaredks commented 4 years ago

Thanks for this! Very clear minimal reproducible sample 👍 I believe it should be corrected in https://github.com/jaredks/rumps/pull/131. Has to do with bytes being returned from pickle (default serializer) in Python 3.

A workaround I suppose is to use another serializer that doesn't fail for Python 3 but it should obviously work out of the box.

jaredks commented 4 years ago

Did anyone test that PR regarding this issue?