Code

Opened 8 years ago

Closed 8 years ago

#2968 closed defect (fixed)

[patch] 2nd/3rd arguments for __import__ are '' (empty string) instead of {} (empty dictionary)

Reported by: Yasushi Masuda <ymasuda@…> Owned by: adrian
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by adrian)

According to Python library reference, the 2nd/3rd arguments of import should be a dictionary
(whatever globals() or locals() returns), but '' (empty strings) are used instead in some part of the code.
It's not fatal because current CPython implementation does not care what type those argument are,
however, it may change in future, or in alternative Python implementation such as IronPython or Jython
(actually, Jython raises ValueError for __import__(mod, '', '', [''])).

Relevant files include: {{{conf/init.py, core/management.py, core/urlresolvers.py, db/init.py,
template/init.py, template/context.py, template/loader.py, templatetags/init.py, test/doctest.py,
test/simple.py, views/debug.py, contrib/auth/init.py, core/cache/init.py, core/handlers/base.py,
core/serializers/init.py, db/models/loading.py, template/loaders/app_directories.py,
contrib/admin/views/doc.py}}}, and contrib/admin/views/template.py.

Attachments (1)

fix_import_args.diff (14.9 KB) - added by Yasushi Masuda <ymasuda@…> 8 years ago.
Patch to fix import args

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by Yasushi Masuda <ymasuda@…>

Patch to fix import args

comment:1 Changed 8 years ago by ymasuda <ymasuda@…>

  • Summary changed from 2nd/3rd arguments for __import__ are '' (empty string) instead of {} (empty dictionary) to [patch] 2nd/3rd arguments for __import__ are '' (empty string) instead of {} (empty dictionary)

comment:2 Changed 8 years ago by adrian

  • Description modified (diff)

Fixed formatting in description.

comment:3 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [3951]) Fixed #2968 -- Changed arguments to import to use empty dictionary instead of empty string, for stricter compliance with Python library reference. Thanks for the patch, Yasushi Masuda

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.