Opened 18 years ago

Last modified 18 years ago

#2968 closed defect

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

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: no UI/UX: no

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.

Change History (3)

by Yasushi Masuda <ymasuda@…>, 18 years ago

Attachment: fix_import_args.diff added

Patch to fix import args

comment:1 by ymasuda <ymasuda@…>, 18 years ago

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 by Adrian Holovaty, 18 years ago

Description: modified (diff)

Fixed formatting in description.

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