Issue1909

classification
Title: attrgetter does not parse dotted attributes
Type: Severity: normal
Components: Library Versions: 2.7a2
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: adorsk, fwierzbicki, int3
Priority: Keywords: patch

Created on 2012-06-06.15:42:05 by adorsk, last changed 2012-06-23.00:49:36 by fwierzbicki.

Files
File name Uploaded Description Edit Remove
attrgetter int3, 2012-06-16.08:59:04 Patch
Messages
msg7183 (view) Author: Alex the Jython User (adorsk) Date: 2012-06-06.15:42:04
The 'attrgetter' method in the 'operator' library does not appear to function as expected.

Environment: jython2.7a2, w/ OpenJDK-6 on Ubuntu 12.04

Test: try running the code below:

class Foo(object):
    pass

class Bar(object):
    pass

f = Foo()
f.bar = Bar()
f.bar.bat = 5

from operator import attrgetter
print attrgetter("bar.bat")(f) 

----
The result is this error:

Traceback (most recent call last):
  File "t.py", line 13, in <module>
    print attrgetter("bar.bat")(f)
AttributeError: 'Foo' object has no attribute 'bar.bat' 


This specifically causes problems when used with SqlAlchemy 0.7.7, as per this thread:

http://groups.google.com/group/sqlalchemy/browse_thread/thread/8dd77dccad818ba6

PS: I'm just getting into Jython, looks like a very cool tool, and potentially very useful as well.
msg7222 (view) Author: Jez Ng (int3) Date: 2012-06-15.07:40:36
This patch fixes the issue.
msg7223 (view) Author: Jez Ng (int3) Date: 2012-06-15.12:04:52
Didn't set up the first patch properly -- here's an updated copy.
msg7232 (view) Author: Jez Ng (int3) Date: 2012-06-16.08:59:04
Third attempt at submitting a proper patch file.
msg7257 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-06-22.20:35:38
Jez: I applied your patch - note that I added the test that adorsk submitted to test_operator_jy.py. Normally I would have bugged you to do that but it's too close to beta time :)
msg7258 (view) Author: Jez Ng (int3) Date: 2012-06-22.22:02:57
There's actually a test for dotted attributes in the original CPython test which I uncommented. :)
msg7259 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2012-06-23.00:49:35
Oops - you know I think I pushed so many of your patches that I probably just got mixed up :) -- I'll delete the redundant test.
History
Date User Action Args
2012-06-23 00:49:36fwierzbickisetmessages: + msg7259
2012-06-22 22:02:57int3setmessages: + msg7258
2012-06-22 20:35:39fwierzbickisetstatus: open -> closed
resolution: fixed
messages: + msg7257
nosy: + fwierzbicki
2012-06-16 08:59:04int3setfiles: + attrgetter
messages: + msg7232
title: attrgetter not working -> attrgetter does not parse dotted attributes
2012-06-16 08:58:29int3setfiles: - attrgetter.diff
2012-06-15 12:04:52int3setfiles: + attrgetter.diff
keywords: + patch
messages: + msg7223
2012-06-15 11:56:38int3setfiles: - attrgetter
2012-06-15 07:40:36int3setfiles: + attrgetter
nosy: + int3
messages: + msg7222
2012-06-06 15:42:05adorskcreate