You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pyobjc does not throw an error and instead returns None when creating something with the wrong arguments. For instance, one proper way to create a CIImage is this:
But if I pass in a string to imageWithContentsOfURL_ method instead of an NSURL, it doesn't throw an error. It simply returns None.
I am very new to pyobjc and even Objective C. I am trying to figure out if I am doing something wrong? Is there any way to make pyobjc throw an error instead of returning None? Or maybe returning None is how it works in Objective C too.
I even tried setting the verbose to True:
importobjcobjc.options.verbose=True
But it didn't improve things. Can you kindly guide what I might be doing wrong? It is very hard to debug bugs without any indication that what I am doing is wrong.
The text was updated successfully, but these errors were encountered:
Sadly the Cocoa frameworks contain limited error checking, mostly relying on the compiler to find problems like this. If Objective-C code raises an exception that exception is automatically translated to a Python exception. The verbose option is primarily present to log exceptions that are later swallowed by a runloop to make it easier to debug code.
There will be type annotations for PyObjC in the future, but adding those is a fair bit of work and may require some work with the type community as well because PyObjC does some things that don't necessarily play nice with type checkers.
For now I generally keep Apple's documentation open when working with APIs that I haven't used enough.
Ah ok this makes sense. Thanks for the quick response. I will close this issue then. Either ways, thanks for all your work! I worked with pyobjc for the first time recently and it is pretty amazing to see what it is capable of :)
pyobjc
does not throw an error and instead returns None when creating something with the wrong arguments. For instance, one proper way to create aCIImage
is this:But if I pass in a string to
imageWithContentsOfURL_
method instead of anNSURL
, it doesn't throw an error. It simply returns None.I am very new to pyobjc and even Objective C. I am trying to figure out if I am doing something wrong? Is there any way to make pyobjc throw an error instead of returning None? Or maybe returning None is how it works in Objective C too.
I even tried setting the verbose to True:
But it didn't improve things. Can you kindly guide what I might be doing wrong? It is very hard to debug bugs without any indication that what I am doing is wrong.
The text was updated successfully, but these errors were encountered: