Issue1376

classification
Title: 'name in dir(item)' holds, but 'getattr(item, name)' fails
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.5
Milestone:
process
Status: open Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: amoebam, boisgera, fwierzbicki, zyasoft
Priority: normal Keywords:

Created on 2009-06-15.10:22:54 by boisgera, last changed 2017-10-10.18:40:18 by amoebam.

Messages
msg4813 (view) Author: (boisgera) Date: 2009-06-15.10:22:53
It seems natural that when 'name in dir(item)' holds, 'getattr(item,
name)' will work. The function inspect.classify_class_attrs for example
requires this property.

AFAICT, this invariant is violated when item is a Java class that
defines some 'getXXX' methods: 'XXX' will appear in dir(Class) but
getattr(Class, 'XXX') won't work. For example:

    >>> from java.lang import *
    >>> "class" in dir(String) # generated from getClass
    True
    >>> getattr(String, "class")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: instance attr: class
    >>> "bytes" in dir(String) # generated from getBytes
    True
    >>> getattr(String, "bytes")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: instance attr: bytes
msg9337 (view) Author: Jim Baker (zyasoft) Date: 2015-01-07.07:46:10
Would be nice to see this work with Java classes
History
Date User Action Args
2017-10-10 18:40:18amoebamsetnosy: + amoebam
2015-01-07 07:46:10zyasoftsetpriority: low -> normal
resolution: remind -> accepted
messages: + msg9337
nosy: + zyasoft
2013-02-26 17:26:47fwierzbickisetnosy: + fwierzbicki
2013-02-19 23:16:10fwierzbickisetpriority: low
resolution: remind
versions: + Jython 2.5, - 25rc4
2009-06-15 10:22:54boisgeracreate