Opened 10 years ago

Closed 10 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 Holovaty
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 Holovaty)

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@…> 10 years ago.
Patch to fix import args

Download all attachments as: .zip

Change History (4)

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

Attachment: fix_import_args.diff added

Patch to fix import args

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

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

comment:2 Changed 10 years ago by Adrian Holovaty

Description: modified (diff)

Fixed formatting in description.

comment:3 Changed 10 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(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

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