Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BadPrototypeError #75

Open
ryanphuang opened this issue Jan 2, 2017 · 3 comments
Open

BadPrototypeError #75

ryanphuang opened this issue Jan 2, 2017 · 3 comments

Comments

@ryanphuang
Copy link

I encountered a BadPrototypeError when using the plugin.

Jan  1 16:44:06 MacBook-Pro-8 Mail[26372]: QuoteFix has encountered a fatal error, and will now terminate.
Jan  1 16:44:06 MacBook-Pro-8 Mail[26372]: An uncaught exception was raised during execution of the main script:
	
	BadPrototypeError: Objective-C expects 1 arguments, Python argument has 2 arguments for <unbound selector set_state_and_title of Menu at 0x11459f1d0>

It looks it's because I installed a new version of pyobjc, which enforces more strictly on the selector mapping: https://pythonhosted.org/pyobjc/core/changelog.html

If these methods are only used from Python and are never used from Objective-C the error can be avoided by decorating these methods with objc.python_method:

class MyObject (NSObject):
@objc.python_method
def mymethod(self, a, b): ...

I added this into the quotefix/menu.py methods, but then it failed with

ImportError: cannot import name MessageHeaders

@robertklep
Copy link
Owner

Thanks for the heads-up.

Did you get that error just by installing a new version of PyObjC, or did you also build the plugin using that version? I build the QF plugin using specific version of Python (and PyObjC) and I honestly thought that the plugin was self-contained (i.e. it shouldn't be influenced by globally installed Python/PyObjC).

@ryanphuang
Copy link
Author

I initially got the error by just just directly using the released .mailbundle. If I uninstall the new version (3.2.1) pyobjc, the errors will be gone. So I thought it has dependency on system-wide pyobjc. But then I realize, there was another .mailbundle plugin in my Mails/Bundles that is compiled with the new version pyobjc. If I remove that .mailbundle, even if I have a 3.2.1 pyobjc installed, the release version QF will without problem.

So in short, you are right, the plugin was self-contained, as long as no other plugins that are compiled with the new pyobjc, QF works for me, but if there's another new plugin or I want to build QF by myself, the errors still exist.

@robertklep
Copy link
Owner

Oh, yeah, that could very well cause issues, because AFAIK only one version of the framework can be active inside the Mail app at any one time (and it's a bit of a gamble which one gets loaded first).

My guess is that after decorating the set_state_and_title method, you just hit the next backward incompatible error :(

At some point I'll try and see if I can install the new PyObjC in such a way that it won't break my current setup (which is a bit fragile, I have to admit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants