Issues

Issue #65 resolved

pyobjc objects can't be inspected

rbpasker avatarrbpasker created an issue
>>> print inspect.getmro(path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 348, in getmro
    _searchbases(cls, result)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 339, in _searchbases
    for base in cls.__bases__:
AttributeError: '__NSTaggedDate' object has no attribute '__bases__'

Comments (4)

  1. Ronald Oussoren

    What version of pyobjc do you use? What is the type of path?

    With /usr/bin/python on an OSX 10.8 system:

    >>> from Foundation import NSMutableArray
    >>> NSMutableArray.__bases__
    (<objective-c class NSArray at 0x7fff7d2281e0>,)
    >>> import inspect
    inspect.getmro(NSMutableArray)
    >>> inspect.getmro(NSMutableArray)
    (<objective-c class NSMutableArray at 0x7fff7d228258>, <objective-c class NSArray at 0x7fff7d2281e0>, <objective-c class NSObject at 0x7fff7df61840>, <objective-c class NIL>, <type 'object'>)
    

    I get simular results with python 3 and an in-development version of PyObjC 3.0 (not yet in this repository)

  2. rbpasker

    ok, inspect.getmro() takes a class, not an instance.

    >>> inspect.getmro(NSMutableArray())
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 348, in getmro
        _searchbases(cls, result)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 339, in _searchbases
        for base in cls.__bases__:
    AttributeError: '__NSArrayM' object has no attribute '__bases__'
    >>> inspect.getmro(NSMutableArray().__class__)
    (<objective-c class __NSArrayM at 0x7fff7c5fd1b8>, <objective-c class NSMutableArray at 0x7fff7c5fd258>, <objective-c class NSArray at 0x7fff7c5fd1e0>, <objective-c class NSObject at 0x7fff7c991840>, <objective-c class NIL>, <type 'object'>)
    >>> 
    
  3. Ronald Oussoren

    That's correct. The MRO is a feature of (new style) classes, not of instances.

    BTW. The same information is also in the mro attribute of new-style classes (all classes in Python 3, and in Python 2 all classes that are subclasses of object).

  4. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.