3.3a0 gives unrecognized option '-d' Usage: atos [-p pid] [-o executable] [-f file] [-s slide | -l loadAddress] [-arch architecture] warning

Issue #189 resolved
Marc Van Olmen
created an issue

I see 2 bugs:

  • unrecognized option '-d' on the atos command.
  • not sure why this error is getting triggered in the first place.

Python 2.7.6 MacOS 10.11.6 Xcode 8.2.1

[invalid usage]: unrecognized option '-d'
Usage: atos [-p pid] [-o executable] [-f file] [-s slide | -l loadAddress] [-arch architecture] [-printHeader] [address ...]

[invalid usage]: unrecognized option '-d'
Usage: atos [-p pid] [-o executable] [-f file] [-s slide | -l loadAddress] [-arch architecture] [-printHeader] [address ...]
2017-05-13 10:35:19.510 Checkout[22908:4501410] *** ObjC exception 'NSInvalidArgumentException' (reason: 'Class OC_PythonObject: no such selector: removeObserver:forKeyPath:context:') discarded
Stack trace (most recent call last):

I just upgraded from PyObjc 3.0 to 3.3a0 and i notice the following error when I try to run my app in py2app --alias mode.

This error doesn't appear in version 3.0

The reason why this error gets triggers is because we do this overwrite, for an error we have in our code:

OC_PythonObject = objc.lookUpClass('OC_PythonObject')


class OC_PythonObject(objc.Category(OC_PythonObject)):

    def removeObserver_forKeyPath_context_(self, observer, keyPath, context):
        pass

if I removed the following code it won't happen.

Comments (7)

  1. Ronald Oussoren repo owner

    This is due to the stack trace formatting code in pyobjc-framework-ExceptionHandling. The relevant code doesn't contain comments and I'm therefore not sure why the "-d" option is used in the first place. I'll probably just remove the option from the invocation of atos.

    I'm not sure why upgrading to 3.3a0 triggers this, this code hasn't changed in a long time. There is likely another issue that triggers the invocation of the objective-C exception logger (and hence atos). Could you remove the "-d" option from the invocation of atos to find out what's going on.

    diff -r a9d2394b19d7 pyobjc-framework-ExceptionHandling/Lib/PyObjCTools/Debugging.py
    --- a/pyobjc-framework-ExceptionHandling/Lib/PyObjCTools/Debugging.py   Wed Apr 19 13:04:26 2017 +0200
    +++ b/pyobjc-framework-ExceptionHandling/Lib/PyObjCTools/Debugging.py   Mon May 15 10:51:18 2017 +0200
    @@ -63,8 +63,6 @@
         if _atos_command is None:
             if os.path.exists('/usr/bin/atos'):
                 _atos_command = '/usr/bin/atos'
    -            if int(os.uname()[2].split('.')[0]) >= 13:
    -                _atos_command += ' -d'
    
             elif os.path.exists('/usr/bin/xcrun'):
                 _atos_command = '/usr/bin/xcrun atos'
    

    P.S. Installing PyObjC from PyPI is more convenient these days, I've started shipping wheels.

    P.P.S. Why do you add a category to OC_PythonObject? Is this application specific or something that should be in PyObjC itself?

  2. Marc Van Olmen reporter

    P.P.S. Why do you add a category to OC_PythonObject? Is this application specific or something that should be in PyObjC itself?

    Indeed this is something app specific this old code is passing regular Python objects (SQLAlchemy) to NSViews that are being observed. I'm to going to fix this by creating Objc Proxy objects around this.

  3. Log in to comment