Issue1255

classification
Title: __import__ fails on any level except 0 with the error str indices must be integers
Type: behaviour Severity: normal
Components: Core Versions: 2.5.1
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, jfenwick, leosoto, pjenvey
Priority: low Keywords:

Created on 2009-01-28.21:01:28 by jfenwick, last changed 2009-07-30.03:22:35 by pjenvey.

Messages
msg4104 (view) Author: Jacob Fenwick (jfenwick) Date: 2009-01-28.21:02:08
Example:
>>> foo = __import__('os', '', '', [''], -1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: str indices must be integers
msg4105 (view) Author: Leonardo Soto (leosoto) Date: 2009-01-29.00:30:55
The second and third arguments to __import__ are supposed to be
dictionaries, not string. What code did you found which uses that idiom?

Changing the offending code to:

  __import__('os', globals(), locals(), [''], -1) 

Should fix the problem 

[But, anyway, I'd like to know where the original code was found]
msg4106 (view) Author: Jacob Fenwick (jfenwick) Date: 2009-01-29.03:30:28
The immediate bug seems to be in django. I found it while testing
django-jython. I have submitted the bug and the patch to django here:
http://code.djangoproject.com/ticket/10144

However, I still think this should be abug against jython, as the test
succeeds in python, whereas it fails in jython. So this means there's
still a difference in how python and jython deal with this situation.
msg4961 (view) Author: Philip Jenvey (pjenvey) Date: 2009-07-30.03:22:35
I'd consider CPython accepting the str args as an implementation detail, 
and a buggy one at that. closing out as this should be fixed in the latest 
django
History
Date User Action Args
2009-07-30 03:22:35pjenveysetstatus: open -> closed
resolution: invalid
messages: + msg4961
nosy: + pjenvey
2009-03-14 14:50:26fwierzbickisetpriority: low
versions: + 2.5.1, - 2.5b1
2009-01-29 03:30:28jfenwicksetmessages: + msg4106
2009-01-29 02:52:56fwierzbickisetnosy: + fwierzbicki
2009-01-29 00:30:56leosotosetmessages: + msg4105
2009-01-28 23:36:13jfenwicksetnosy: + leosoto
2009-01-28 21:02:13jfenwicksetmessages: + msg4104
2009-01-28 21:01:29jfenwickcreate