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

HIServices.AXIsProcessTrustedWithOptions raises with 8.1/8.4 working with 7.1 #456

Closed
barak10 opened this issue Mar 10, 2022 · 5 comments
Closed

Comments

@barak10
Copy link

barak10 commented Mar 10, 2022

Recently we have upgraded to pyobjc 8.1
Code that is working on 7.1 have started to raise:

import HIServices
from ApplicationServices import kAXTrustedCheckOptionPrompt
HIServices.AXIsProcessTrustedWithOptions({kAXTrustedCheckOptionPrompt: True})

In 7.1 is pops up the accessibility dialog as expected, but with 8.1/8.4 is raises with:
objc.internal_error: PyObjC: internal error in PyObjCFFI_ParseArguments at Modules/objc/libffi_support.m:3238: assertion failed: argbuf_cur <= argbuf_len

@ronaldoussoren
Copy link
Owner

Thanks. This is a bug in the bindings for this API.

A quick workaround:

  • Look for AXIsProcessTrustedWithOption in HIServers/_metadata.py, it should look like this:

    "AXIsProcessTrustedWithOptions": (b"Zo^{__CFDictionary=}",),

  • Remove the "o" just before "^". The new version then looks like:

    "AXIsProcessTrustedWithOptions": (b"Z^{__CFDictionary=}",),

With this you code no longer raises.

There will be a bugfix release later this week that will include this fix as well. This issue will stay open a little longer because the exception itself is wrong as well and that needs further investigation.

@barak10
Copy link
Author

barak10 commented Mar 10, 2022

Thanks so much for your quick response!
Apparently that's what I have:
"AXIsProcessTrustedWithOptions": ( b"Z^{__CFDictionary=}", "", {"arguments": {0: {"type_modifier": "o"}}}, ),

@barak10
Copy link
Author

barak10 commented Mar 10, 2022

Thanks so much for your quick response! Apparently that's what I have: "AXIsProcessTrustedWithOptions": ( b"Z^{__CFDictionary=}", "", {"arguments": {0: {"type_modifier": "o"}}}, ),

To clarify, that is what I have with 8.1 and it does raises

@ronaldoussoren
Copy link
Owner

I should have looked more carefully: remove"type_modifier": "o" from this line, that should fix this issue for now.

@barak10
Copy link
Author

barak10 commented Mar 16, 2022

Thanks so much for your prompt fix!

@barak10 barak10 closed this as completed Mar 16, 2022
ronaldoussoren added a commit that referenced this issue Mar 20, 2022
Related to #456: Add an assertion to PyObjCTools.TestSupport
that does (currently very) basic checking of metadata for
callables.

Use this new method in the bindings for all frameworks.

Fix the 2 issues found by this test.
ronaldoussoren added a commit that referenced this issue Mar 20, 2022
* Add constants for the 'A' and 'j' characters in type encoding
* Basic implementation for 'A' in objc_support

The implemtation is not entirely correct, the prefix denotes
an atomic varialble and should be read/written using atomic
instructions. The prefix is currently ignored, that should be
good enough for now.

The 'j' prefix is not supported by the bridge, and is not
used in public APIs.
ronaldoussoren added a commit that referenced this issue Mar 20, 2022
…n type

This is related to #456, and avoids hitting an internal assertion
error with invalid metadata for a function/method. The assertion
error indicates a programming error in the bridge itself, and those
assertions are something that I'll disable for production builds
in a future version (which would have resulted in memory corruption
in this case).
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