Opened 15 years ago

Closed 15 years ago

#10144 closed (duplicate)

get_comment_app calls __import__ with strings instead of dictionaries for 2nd and 3rd arguments

Reported by: Jacob Fenwick Owned by: Jacob Fenwick
Component: Testing framework Version: 1.0
Severity: Keywords: comments jython
Cc: Leo Soto M. Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

When the comment_tests test is run under jython, I get this error:

======================================================================
ERROR: testGetCommentApp (regressiontests.comment_tests.tests.app_api_tests.CommentAppAPITests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jacob/projects/djython/django-1.0.X/tests/regressiontests/comment_tests/tests/app_api_tests.py", line 11, in testGetCommentApp
    self.assertEqual(comments.get_comment_app(), comments)
  File "/Users/jacob/projects/djython/django-1.0.X/django/contrib/comments/__init__.py", line 20, in get_comment_app
    package = __import__(comments_app, '', '', [''])
  File "/Users/jacob/projects/djython/django-1.0.X/django/contrib/comments/__init__.py", line 20, in get_comment_app
    package = __import__(comments_app, '', '', [''])
TypeError: str indices must be integers

The problem is that the import function is taking a string for the second and third arguments when the parameters should be dictionaries. Python seems to coerce the strings into the correct format, but jython does not.

Here is the patch, which should be applied to all version of django:

svn diff init.py

Index: __init__.py
===================================================================
--- __init__.py	(revision 9791)
+++ __init__.py	(working copy)
@@ -17,7 +17,7 @@
 
     # Try to import the package
     try:
-        package = __import__(comments_app, '', '', [''])
+        package = __import__(comments_app, globals(), locals(), [''])
     except ImportError:
         raise ImproperlyConfigured("The COMMENTS_APP setting refers to "\
                                    "a non-existing package.")

Attachments (2)

patch.txt (569 bytes ) - added by Jacob Fenwick 15 years ago.
Patch for init.py
patch2.txt (613 bytes ) - added by Jacob Fenwick 15 years ago.
Did the svn diff from the trunk instead of on the file (oops)

Download all attachments as: .zip

Change History (6)

by Jacob Fenwick, 15 years ago

Attachment: patch.txt added

Patch for init.py

comment:1 by Ramiro Morales, 15 years ago

Description: modified (diff)

(reformatted description)

comment:2 by Jacob Fenwick, 15 years ago

Owner: changed from nobody to Jacob Fenwick
Status: newassigned

by Jacob Fenwick, 15 years ago

Attachment: patch2.txt added

Did the svn diff from the trunk instead of on the file (oops)

comment:3 by Leo Soto M., 15 years ago

Cc: Leo Soto M. added
Keywords: jython added

comment:4 by Jacob, 15 years ago

Resolution: duplicate
Status: assignedclosed

Duplicate of (well, would be solved by) #8193.

Note: See TracTickets for help on using tickets.
Back to Top