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

GSAnchor doesn't accept arguments when creating an instance via Python #94

Open
takaakifuji opened this issue Oct 28, 2024 · 2 comments

Comments

@takaakifuji
Copy link

anchor = GSAnchor('top', NSPoint(100, 100))

The code above fails with the error TypeError: GSAnchor() does not accept positional arguments. Looks like the line

GSAnchor.__new__ = staticmethod(GSObject__new__)

has been somehow missing in the G3 wrapper.

$ diff -u <(curl -sL 'https://raw.githubusercontent.com/schriftgestalt/GlyphsSDK/refs/heads/master/ObjectWrapper/GlyphsApp/__init__.py' | grep '\.__init__' | cut -d' ' -f1 | sort | sed 's/\.__init__//g') <(curl -sL 'https://raw.githubusercontent.com/schriftgestalt/GlyphsSDK/refs/heads/master/ObjectWrapper/GlyphsApp/__init__.py' | grep '\.__new__' | cut -d' ' -f1 | sort | sed 's/\.__new__//g') | grep '^-GS'
-GSAnchor
-GSBackgroundImage
-GSComponent
-GSGuideLine
-GSNode

Just in case the classes listed above might need the same fix. I hope you could look into this when you have time.

@schriftgestalt
Copy link
Owner

schriftgestalt commented Oct 28, 2024

I was testing in python 3.11 and it works there. But from Python 3.12 it doesn’t. I’ll fix it.

@takaakifuji
Copy link
Author

Thanks for your response! I realised I was using the latest pyobjc==10.3.1. I think it works okay if I downgrade it to 10.0.0, which is the version that comes with GlyphPythonPlugin.

https://pyobjc.readthedocs.io/en/latest/changelog.html#version-10-3
Instantiating an Objective-C class by calling the class (e.g. invoking new) will not call init even if one is defined

PyObjC 10.3 seems to have a breaking change.

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