Opened 17 years ago

Last modified 16 years ago

#6579 closed

Importing empty symbol causes double initialization of some modules — at Initial Version

Reported by: Grzegorz Lukasik <hauserx@…> Owned by: nobody
Component: Template system Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In file templatetags/init.py there is a line:

__path__.extend(__import__(a + '.templatetags', {}, {}, ['']).__path__)

import method as fourth parameters gets a list of symbols to import. If this list is empty, import returns the top-level package, but if the list contains anything the specified package is returned as described in http://docs.python.org/lib/built-in-funcs.html . So in this file there is a hack where not empty list but list that contains 'something' is passed - list that contains single empty name.

But it causes some strange side-effects - the specified module is initialized twice. First with correct name and later with name followed by a dot (e.g. 'prog.app.templatetags' and 'prog.app.templatetags.' ). In some cases it may cause serious problems.

Change History (1)

by Grzegorz Lukasik <hauserx@…>, 17 years ago

Attachment: double_init.patch added
Note: See TracTickets for help on using tickets.
Back to Top