Issues

Issue #82 resolved

PyObjc 3.0 (default branch) Python iterators on NSArray generating exceptions

Marc Van Olmen
created an issue

hi,

Turning on

from PyObjCTools import Debugging
Debugging.installVerboseExceptionHandler()

Iterating over for example :

    # Categorize devices
    for keyboard in DDHidLib.DDHidKeyboard.allKeyboards():
        # Don't recheck devices that have been categorized already
        # NSLog(u'%@', unicode(keyboard.descriptionDictionary()))

Also this iterator:

     for subview in self.tabView.subviews():
    if subview.isKindOfClass_(SFTabButton):
              tabsByOriginXDict[Foundation.NSMinX(subview.frame())] = subview

generating exceptions like:

2014-05-17 10:35:59.072 Checkout[51943:303] *** ObjC exception 'NSRangeException' (reason: '*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]') discarded
Stack trace (most recent call last):
  PyObjCNativeSelector_Type (in _objc.so) + 0
  objcsel_call (in _objc.so) + 228
  PyObjCFFI_Caller (in _objc.so) + 3305
  ffi_call (in _objc.so) + 125
  ffi_call_SYSV (in _objc.so) (x86-darwin-Kjl12T.s:63)
  -[__NSArrayM objectAtIndex:] (in CoreFoundation) + 251
  objc_exception_throw (in libobjc.A.dylib) + 230
  NSExceptionHandlerExceptionRaiser (in ExceptionHandling) + 211

Comments (6)

  1. Ronald Oussoren repo owner

    NSArray.__iter__ got lost during the transition to PyObjC 3.0, I'm adding it back in.

    Futhermore PyObjCTools.Debugging appears to be too aggressive in logging exceptions (the exception is there, but is caught and handled by Python code). I'm not sure what I can do about this.

  2. Ronald Oussoren repo owner

    The aggressive logging of exceptions is already present in 2.3 and is not a new problem. There doesn't seem to be a way to detect that the exception was actually caught.

  3. Log in to comment