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

Is executeVanillaTest broken? #211

Closed
justinpenner opened this issue Jun 1, 2024 · 5 comments
Closed

Is executeVanillaTest broken? #211

justinpenner opened this issue Jun 1, 2024 · 5 comments

Comments

@justinpenner
Copy link

I can't get a simple test from the command line to work, at all.

import vanilla
from vanilla.test.testTools import executeVanillaTest
print(vanilla.__version__)

class MyWindow:
    def __init__(self):
        self.w = vanilla.Window(
            (1000, 600),
            "Test",
        )
        self.w.open()

executeVanillaTest(MyWindow)

Output:

0.5.0
Traceback (most recent call last):
  File "./vanilla_test.py", line 13, in <module>
    executeVanillaTest(MyWindow)
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/vanilla/test/testTools.py", line 59, in executeVanillaTest
    cls(**kwargs)
  File "./vanilla_test.py", line 11, in __init__
    self.w.open()
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/vanilla/vanillaWindows.py", line 266, in open
    if self._window is None:
       ^^^^^^^^^^^^
AttributeError: 'Window' object has no attribute '_window'

So, it seems like when I instantiate vanilla.Window, its __init__ method isn't getting called for some reason.

@justinpenner
Copy link
Author

I just discovered that this problem is unique to pyobjc 10.3. If I downgrade to pyobjc 10.2 it resolves this issue and my test window opens:

image

Additionally, pyobjc 10.3 breaks vanilla when I use it in a Glyphs plugin (running vanilla 0.5.0), with the following errors:

image

@justinpenner
Copy link
Author

I'm nowhere near able to wrap my head around pyobjc yet, but I suspect the problem could be related to this change from the 10.3 release notes:

  • Instantiating an Objective-C class by calling the class (e.g. invoking
    __new__) will not call __init__ even if one is defined.

@justvanrossum
Copy link
Collaborator

Your suspicion could be right, it may be this: ronaldoussoren/pyobjc#610

@justvanrossum
Copy link
Collaborator

justvanrossum commented Jun 7, 2024

Yes, it is, vanilla.Window uses that exact pattern with __new__ and __init__.

@justinpenner
Copy link
Author

This is fixed as of pyobjc 10.3.1.

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