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

Passing an empty argument to Cocoa app produces AttributeError #1774

Closed
mhsmith opened this issue Feb 9, 2023 · 2 comments · Fixed by #2075
Closed

Passing an empty argument to Cocoa app produces AttributeError #1774

mhsmith opened this issue Feb 9, 2023 · 2 comments · Fixed by #2075
Labels
bug A crash or error in behavior. macOS The issue relates to Apple macOS support.

Comments

@mhsmith
Copy link
Member

mhsmith commented Feb 9, 2023

% briefcase run -- "" 
...
Exception ignored on calling ctypes callback function: <rubicon.objc.api.objc_method object at 0x10e2fa250>
Traceback (most recent call last):
  File "/Users/msmith/git/beeware/apps/passthrough/macOS/app/passthrough/passthrough.app/Contents/Resources/app_packages/rubicon/objc/api.py", line 333, in __call__
    result = self.py_method(py_self, *args)
  File "/Users/msmith/git/beeware/apps/passthrough/macOS/app/passthrough/passthrough.app/Contents/Resources/app_packages/toga_cocoa/app.py", line 96, in application_openFiles_
    self.impl.open_document(str(fileURL.absoluteString))
AttributeError: 'NoneType' object has no attribute 'absoluteString'

It appears to be harmless, and connected to the undocumented DocumentApp API.

@mhsmith mhsmith added bug A crash or error in behavior. macOS The issue relates to Apple macOS support. labels Feb 9, 2023
@freakboy3742
Copy link
Member

It's a bit of an edge case - in "normal operation", you wouldn't be able to start an app with an empty string as an argument. Still worth catching (and ignoring) the argument, though.

@mhsmith
Copy link
Member Author

mhsmith commented Feb 10, 2023

For future reference: application_openFiles_ is a method which Cocoa may call at any time, not just during app startup. This was added to allow multiple open commands to be handled by the same process, as is the standard behavior on macOS. See Podium for an example.

The GTK backend has a more generic implementation which is based only on sys.argv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. macOS The issue relates to Apple macOS support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants