quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Hawkins <pe...@hawkins.emu.id.au>
Subject Fwd: libapache2-mod-python.deb
Date Mon, 28 Jun 2004 00:30:13 GMT
Hi...

I received the following message... Please apply if appropriate?

=)
Peter

----------  Forwarded Message  ----------

Subject: libapache2-mod-python.deb
Date: Mon, 28 Jun 2004 10:20 am
From: Byron Ellacott <bje@apnic.net>
To: Peter Hawkins <peterh@debian.org>

Hi,

On the 9th of June, I wrote to the mod_python list mentioning a bug with
apache.py's import_module() method.  Somewhat strangely, I didn't hear
/anything/ back from the mod_python developers, neither "great, thanks"
nor "wtf? stfu n00b!"  I also couldn't find any mod_python bug tracking
system.

So, I'm sending the patch to you as the Debian maintainer, in case you'd
like to apply the patch to the upstream source, and save me applying the
patch for each upstream release. ;)

The bug occurs due to the way import_module() imports namespaced
modules.  Say you define a PythonHandler of foo.bar.  import_module()
will use imp.load_module() for foo, then foo.bar.  For each load, this
creates an entry in sys.modules[] for the appropriate name.  However,
import_module does /not/ update the sys.modules['foo'] to contain bar =
sys.modules['foo.bar'].

This means that a subsequent "import foo.bar" checks the sys.modules[]
list for "foo.bar" and, finding it, does nothing.  An attempt to access
foo.bar.Thing will throw an exception, because there's no bar attribute
of module foo.

The patch simply sets the bar attribute in module foo to the freshly
loaded module object.

(Patch made against 3.1.3-1)

--
bje

-------------------------------------------------------



Mime
View raw message