quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Dumpleton <grah...@dscpl.com.au>
Subject Re: mod_python.publisher : proposal for a few implementation changes
Date Sat, 30 Apr 2005 12:50:16 GMT

On 30/04/2005, at 10:24 PM, Nicolas Lehuen wrote:
> So, all this relies on the default platform encoding. How nice. The
> reason why you don't find sys.setdefaultencoding() is because this
> method is deleted from the module after the module is loaded,
> presumably to prevent developers to change the default encoding on the
> fly. I remember being mad at Python when I first discovered that (I
> was trying to remove this dumb 'ascii' default encoding).

It would only be removed though after the Python site setup file has 
executed. Ie., if I remember correctly, you can change the default 
by adding a call to sys.setdefaultencoding() in the site file.

To me this suggests even more that adding a feature to mod_python which
would allow a directive in the Apache configuration file to set the
default encoding would be a good idea. As I said, it would have to be
at same scope as PythonImport and done when the interpreter is first
created but before any code is executed within the scope of the

If this was provided, it would certainly be a lot easier than having to
add something to the Python site file. Not even sure where that is.

Python FAQ has the following to say about this sort of stuff:

   It's possible to set a default encoding in a file called 
   that's part of the Python library. However, this isn't recommended 
   changing the Python-wide default encoding may cause third-party 
   modules to fail.

How much grief could we cause for third party modules by playing with 
Remember that because it would be set by mod_python, only affecting 
running under mod_python and haven't destroyed anything else running on
the system.


View raw message