robotools / vanilla

A Pythonic wrapper around Cocoa.
MIT License
78 stars 28 forks source link

Is executeVanillaTest broken? #211

Closed justinpenner closed 4 months ago

justinpenner commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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:

justvanrossum commented 4 months ago

Your suspicion could be right, it may be this: https://github.com/ronaldoussoren/pyobjc/issues/610

justvanrossum commented 4 months ago

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

justinpenner commented 4 months ago

This is fixed as of pyobjc 10.3.1.