[4.2.5] locale= and lang= not working

263 views
Skip to first unread message

Nikolai Prokoschenko

unread,
Dec 5, 2014, 7:06:42 AM12/5/14
to mod...@googlegroups.com
Hello,

I'm running our Django application on mod_wsgi on a SLES11 SP3 installation. SLES' apache2 doesn't have an envvars file and also resets all environment variables before start so I used to patch its init.d script to include LANG and LC_ALL in the main process.

So far I'm using mod_wsgi 3.3 but I'm about to upgrade to 4.2.5, so I figured I could throw that patch away and use lang= and locale= parameters to WSGIDaemonProcess. I've added "lang=de_DE.UTF-8 locale=de_DE.UTF-8" to the WSGIDaemonProcess line, however, it doesn't seem to work at all.

What I know:

1. Options get accepted by mod_wsgi (no error on startup)
2. Debug logging works (I'm getting mod_wsgi messages with debug level in the apache error log if LogLevel is set to "debug")
3. I do NOT get any logs about activated locale and lang settings (which should be there in debug log level according to https://github.com/GrahamDumpleton/mod_wsgi/blob/4.2.5/src/server/mod_wsgi.c#L8860)
4. Locale settings do NOT work (application crashes where files with UTF-8 encoded filenames are accessed)

I tried reading the mod_wsgi code, which doesn't seem to be broken, but I still don't see how 1, 2 and 3 are possible simultaneously. Is there something I might be missing?

I'm thankful for any ideas.

Nikolai.


Graham Dumpleton

unread,
Dec 5, 2014, 2:53:13 PM12/5/14
to mod...@googlegroups.com
Are you sure your application is actually running in daemon mode and not embedded mode?


Many people set WSGIDaemonProcess but don't actually use WSGIProcessGroup and so they are still running in embedded mode, meaning you wouldn't pick up the lang/local settings from daemon mode.

Are you using IP addresses in the VirtualHost directive line?

There is a suspected issue with logging where logging doesn't come out in some cases where an IP address was used in VirtualHost directive.

Also make sure you are looking in main Apache error log and not just the virtual host error log.

Finally, when you say you are about to upgrade, in testing you are actually using 4.2.5 to validate behaviour?

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Nikolai Prokoschenko

unread,
Dec 5, 2014, 6:04:27 PM12/5/14
to mod...@googlegroups.com
Hello Graham,

NB: That's a work project and I'm on weekend now, so I'll only be able to try something practical on Monday morning CET.


On Friday, December 5, 2014 8:53:13 PM UTC+1, Graham Dumpleton wrote:

Are you sure your application is actually running in daemon mode and not embedded mode?

Pretty sure, that's something I've verified a long time ago. But of course a valid point, I'm going to recheck just to be 100% sure.
 
Are you using IP addresses in the VirtualHost directive line?

There is a suspected issue with logging where logging doesn't come out in some cases where an IP address was used in VirtualHost directive.

This might be (though I think it's a wildcard), I'll have to check when I'm at work again.
 
Also make sure you are looking in main Apache error log and not just the virtual host error log.

This strikes me as the most obvious explanation -- I indeed haven't looked at the main error log, thinking that mod_wsgi is local to a virtual host so to speak (which is obviously wrong for third party modules like mod_wsgi). Again, I'll have to check, but I'm currently 80% certain, that this will explain the missing logs issue. It doesn't, however, explain why there are still encoding errors.
 
Finally, when you say you are about to upgrade, in testing you are actually using 4.2.5 to validate behaviour?

I'm afraid I do not get exactly what you are asking (knowing your blog posts and documentation you seem to have something in mind so I want to give as precise an answer as it gets). I'll try to describe the setup: like I mentioned earlier, we are currently using mod_wsgi 3.3 on SuSE Linux Enterprise 11 and I wanted to upgrade to at least 3.4 to get the locale feature. However, since 4.2.5 packages of mod_wsgi for SLE11 are readily available from http://build.opensuse.org and I haven't found any obvious blockers and incompatibilites in the release notes, I've decided to try that first. I certainly could try 3.5 (3.4 + security fix, right?) first to be as close to production version as possible, but that would require building a proper package by myself, which I didn't see the reason to. The testing goes like this: we put up a properly installed test server instance with mod_wsgi 3.3 and a patched apache2's init.d script, verify that said encoding problem is nowhere to be seen, upgrade mod_wsgi to 4.2.5 and remove the init.d workaround, then verify that encoding problems are there again. The last step has been to add lang and locale options to WSGIDaemonProcess and check again -- problems should be gone then. This is where it failed, I'm still getting those encoding errors.

I hope this answers your question at least a bit.

Thank you for your help so far.

Nikolai.

Nikolai Prokoschenko

unread,
Dec 8, 2014, 6:11:10 AM12/8/14
to mod...@googlegroups.com
Hello Graham,

a quick update after I looked up what's in our installation:


On Saturday, December 6, 2014 12:04:27 AM UTC+1, Nikolai Prokoschenko wrote:
Are you sure your application is actually running in daemon mode and not embedded mode?
Pretty sure, that's something I've verified a long time ago. But of course a valid point, I'm going to recheck just to be 100% sure.

Yes, it does.
 
Are you using IP addresses in the VirtualHost directive line?
This might be (though I think it's a wildcard), I'll have to check when I'm at work again.

Wildcard confirmed, <VirtualHost *:443>
 
Also make sure you are looking in main Apache error log and not just the virtual host error log.

Yes indeed, that was it. Main apache error log showed correct and expected output. 

There is still the actual encoding problem, I'd like to provide a minimal test case but that'll have to wait until tomorrow for time reasons. In short terms: os.stat(path) where path is something UTF-8 encoded (with diacritics and such) crashes with UnicodeDecodeError.

Nikolai.

Nikolai Prokoschenko

unread,
Dec 8, 2014, 6:57:30 AM12/8/14
to mod...@googlegroups.com
Hello again,


On Monday, December 8, 2014 12:11:10 PM UTC+1, Nikolai Prokoschenko wrote:
There is still the actual encoding problem, I'd like to provide a minimal test case but that'll have to wait until tomorrow for time reasons. In short terms: os.stat(path) where path is something UTF-8 encoded (with diacritics and such) crashes with UnicodeDecodeError.

I've had a couple of minutes to craft this minimal wsgi application, which fails with lang=de_DE.UTF-8 locale=de_DE.UTF-8:

#!/usr/bin/python
# coding: utf-8

import os

filename = u"/tmp/äöü.gif"

def minimal_application(environ, start_response):
    start_response('200 OK', [('content-type', 'text/plain')])
    os.stat(filename)
    return (filename, )

application = minimal_application

Graham Dumpleton

unread,
Dec 8, 2014, 9:56:26 PM12/8/14
to mod...@googlegroups.com
Technically that example is not WSGI compliant.

Can you provide me the full traceback so I can see where the error is occurring?

The problem with the example is that the iterable returned should be over a sequence of bytes strings, not Unicode strings.

Can you also add in the following prior to the os.stat() and provide what the logs say:

    import os
    import sys
    import locale
    import mod_wsgi

    print('process_group', mod_wsgi.process_group)
    print('application_group', mod_wsgi.application_group)

    print('LANG', os.environ.get('LANG'))
    print('LC_ALL', os.environ.get('LC_ALL'))

    print('sys.getdefaultencoding()', sys.getdefaultencoding())

    print('locale.getlocale()', locale.getlocale())
    print('locale.getdefaultlocale()', locale.getdefaultlocale())
    print('locale.getpreferredencoding()', locale.getpreferredencoding())

Graham

    

Nikolai Prokoschenko

unread,
Dec 9, 2014, 4:29:54 AM12/9/14
to mod...@googlegroups.com
Hi,

On Tuesday, December 9, 2014 3:56:26 AM UTC+1, Graham Dumpleton wrote:
The problem with the example is that the iterable returned should be over a sequence of bytes strings, not Unicode strings.

I suppose using str(filename) in return statement is enough to be compliant?
 
Can you also add in the following prior to the os.stat() and provide what the logs say:

Of course (slightly anonymized):
 
[Tue Dec 09 10:22:04 2014] [error] ('process_group', 'my_application')
[Tue Dec 09 10:22:04 2014] [error] ('application_group', '')
[Tue Dec 09 10:22:04 2014] [error] ('LANG', 'de_DE.UTF-8')
[Tue Dec 09 10:22:04 2014] [error] ('LC_ALL', 'POSIX')
[Tue Dec 09 10:22:04 2014] [error] ('sys.getdefaultencoding()', 'ascii')
[Tue Dec 09 10:22:04 2014] [error] ('locale.getlocale()', ('de_DE', 'UTF8'))
[Tue Dec 09 10:22:04 2014] [error] ('locale.getdefaultlocale()', (None, None))
[Tue Dec 09 10:22:04 2014] [error] ('locale.getpreferredencoding()', 'ANSI_X3.4-1968')
[Tue Dec 09 10:22:04 2014] [error] [client 10.250.205.193] mod_wsgi (pid=29728): Exception occurred processing WSGI script '/srv/my_application/app/wsgi.py'.
[Tue Dec 09 10:22:04 2014] [error] [client 10.250.205.193] Traceback (most recent call last):
[Tue Dec 09 10:22:04 2014] [error] [client 10.250.205.193]   File "/srv/my_application/app/wsgi.py", line 28, in minimal_application
[Tue Dec 09 10:22:04 2014] [error] [client 10.250.205.193]     os.stat(filename)
[Tue Dec 09 10:22:04 2014] [error] [client 10.250.205.193] UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-7: ordinal not in range(128)

I notice that LC_ALL is set to POSIX, which is probably where the error lies, getpreferredencoding() is probably just following that. I'll check again whether I've got anything wrong with the configuration.

Nikolai.

Graham Dumpleton

unread,
Dec 9, 2014, 4:38:53 AM12/9/14
to mod...@googlegroups.com
On 09/12/2014, at 8:29 PM, Nikolai Prokoschenko <nik...@prokoschenko.de> wrote:

Hi,

On Tuesday, December 9, 2014 3:56:26 AM UTC+1, Graham Dumpleton wrote:
The problem with the example is that the iterable returned should be over a sequence of bytes strings, not Unicode strings.

I suppose using str(filename) in return statement is enough to be compliant?

One shouldn't use str() as that then depends on system encoding, which can trust. You should use encode() method of Unicode string explicitly.

  output.encode('UTF-8')

The encoding should actually be what every encoding the content type response header said was being used.

 
Can you also add in the following prior to the os.stat() and provide what the logs say:

Of course (slightly anonymized):
 
[Tue Dec 09 10:22:04 2014] [error] ('process_group', 'my_application')
[Tue Dec 09 10:22:04 2014] [error] ('application_group', '')
[Tue Dec 09 10:22:04 2014] [error] ('LANG', 'de_DE.UTF-8')
[Tue Dec 09 10:22:04 2014] [error] ('LC_ALL', 'POSIX')
[Tue Dec 09 10:22:04 2014] [error] ('sys.getdefaultencoding()', 'ascii')
[Tue Dec 09 10:22:04 2014] [error] ('locale.getlocale()', ('de_DE', 'UTF8'))
[Tue Dec 09 10:22:04 2014] [error] ('locale.getdefaultlocale()', (None, None))
[Tue Dec 09 10:22:04 2014] [error] ('locale.getpreferredencoding()', 'ANSI_X3.4-1968')
[Tue Dec 09 10:22:04 2014] [error] [client 10.250.205.193] mod_wsgi (pid=29728): Exception occurred processing WSGI script '/srv/my_application/app/wsgi.py'.
[Tue Dec 09 10:22:04 2014] [error] [client 10.250.205.193] Traceback (most recent call last):
[Tue Dec 09 10:22:04 2014] [error] [client 10.250.205.193]   File "/srv/my_application/app/wsgi.py", line 28, in minimal_application
[Tue Dec 09 10:22:04 2014] [error] [client 10.250.205.193]     os.stat(filename)
[Tue Dec 09 10:22:04 2014] [error] [client 10.250.205.193] UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-7: ordinal not in range(128)

I notice that LC_ALL is set to POSIX, which is probably where the error lies, getpreferredencoding() is probably just following that. I'll check again whether I've got anything wrong with the configuration.

The one that worried me is:

('locale.getpreferredencoding()', 'ANSI_X3.4-1968')

I really don't understand exactly how some of those get set and what they are meant to indicate. It is entirely possible that my attempts to override them are wrong.

        if (daemon->group->lang) {
            char *envvar = apr_pstrcat(p, "LANG=", daemon->group->lang, NULL);
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, wsgi_server,
                         "mod_wsgi (pid=%d): Setting lang to %s.",
                         getpid(), daemon->group->lang);
            putenv(envvar);
        }

        if (daemon->group->locale) {
            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, wsgi_server,
                         "mod_wsgi (pid=%d): Setting locale to %s.",
                         getpid(), daemon->group->locale);
            setlocale(LC_ALL, daemon->group->locale);
        }

So 'LANG' is set by setting the environment variable, but locale is set by using setlocale() as it is already set by C libraries from LC_ALL environment variable.

I can't remember why I though that setting LANG environment variable was enough. Right now doing that doesn't seem right.

Just so have full context, can you provide the full WSGIDaemonProcess directive line so can see everything that is being set.

Thanks.

Graham

Nikolai Prokoschenko

unread,
Dec 9, 2014, 4:45:16 AM12/9/14
to mod...@googlegroups.com
Hi Graham,

just to extend on what I've written before: the main apache log is of course logging the following:

[Tue Dec 09 10:41:28 2014] [debug] src/server/mod_wsgi.c(8864): mod_wsgi (pid=5990): Setting lang to de_DE.UTF-8.
[Tue Dec 09 10:41:28 2014] [debug] src/server/mod_wsgi.c(8871): mod_wsgi (pid=5990): Setting locale to de_DE.UTF-8.

On Tuesday, December 9, 2014 10:38:53 AM UTC+1, Graham Dumpleton wrote:
Just so have full context, can you provide the full WSGIDaemonProcess directive line so can see everything that is being set.

Again, slightly anonymized:

WSGIDaemonProcess my_application user=app_user group=app_group lang=de_DE.UTF-8 locale=de_DE.UTF-8 processes=20 threads=1 display-name=%{GROUP} python-path=/srv/my_application/virtualenv/lib/python2.6/site-packages

WSGIProcessGroup my_application

WSGIApplicationGroup %{GLOBAL}

Nikolai

Graham Dumpleton

unread,
Dec 9, 2014, 4:55:53 AM12/9/14
to mod...@googlegroups.com
Is the environment variable LC_CTYPE set separately?

The code for getpreferredencoding() is really weird.

        def getpreferredencoding(do_setlocale = True):
            """Return the charset that the user is likely using,
            according to the system configuration."""
            if do_setlocale:
                oldloc = setlocale(LC_CTYPE)
                try:
                    setlocale(LC_CTYPE, "")
                except Error:
                    pass
                result = nl_langinfo(CODESET)
                setlocale(LC_CTYPE, oldloc)
                return result
            else:
                return nl_langinfo(CODESET)

Graham

Nikolai Prokoschenko

unread,
Dec 9, 2014, 4:59:09 AM12/9/14
to mod...@googlegroups.com
On Tuesday, December 9, 2014 10:55:53 AM UTC+1, Graham Dumpleton wrote:
Is the environment variable LC_CTYPE set separately?

Since I'm on SLES11 which does "export -n ${!APACHE_*}" just before apache start, I'd say no way it's being set separately.

Nikolai.

Nikolai Prokoschenko

unread,
Dec 12, 2014, 6:58:02 AM12/12/14
to mod...@googlegroups.com
Graham,

I'm sorry to nudge, but still wanted to know if you had any new ideas on this issue.

Thanks
Nikolai.

Graham Dumpleton

unread,
Dec 12, 2014, 6:03:14 PM12/12/14
to mod...@googlegroups.com
I had a little play, but have been hammered this week with things so trying to juggle a lot of things.

When I did try with what I thought we be same set up MacOS X, had no issues. I need to try on a Linux system under Docker and perhaps work out how to build up the specific Linux variant you are using under Docker.

Just though so I have everything that might affect OS and what it does, can you provide me a dump of of os.environ from just before the line that fails.

Graham

Nikolai Prokoschenko

unread,
Dec 16, 2014, 8:52:28 AM12/16/14
to mod...@googlegroups.com
Hello Graham,


On Saturday, December 13, 2014 12:03:14 AM UTC+1, Graham Dumpleton wrote:
Just though so I have everything that might affect OS and what it does, can you provide me a dump of of os.environ from just before the line that fails.

Based on previous minimal application:

[Tue Dec 16 14:48:37 2014] [error] ('process_group', 'myapp')
[Tue Dec 16 14:48:37 2014] [error] ('application_group', '')
[Tue Dec 16 14:48:37 2014] [error] ('LANG', 'de_DE.UTF-8')
[Tue Dec 16 14:48:37 2014] [error] ('LC_ALL', 'POSIX')
[Tue Dec 16 14:48:37 2014] [error] ('sys.getdefaultencoding()', 'ascii')
[Tue Dec 16 14:48:37 2014] [error] ('locale.getlocale()', ('de_DE', 'UTF8'))
[Tue Dec 16 14:48:37 2014] [error] ('locale.getdefaultlocale()', (None, None))
[Tue Dec 16 14:48:37 2014] [error] ('locale.getpreferredencoding()', 'ANSI_X3.4-1968')
[Tue Dec 16 14:48:37 2014] [error] {'LC_NUMERIC': '', 'LINES': '64', 'LC_CTYPE': '', 'OPENSSL_NO_DEFAULT_ZLIB': '1', 'LOGNAME': 'myuser', 'USER': 'myuser', 'get_module_list_done': 'true', 'LC_PAPER': '', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'LANG': 'de_DE.UTF-8', 'TERM': 'xterm256', 'SHELL': '/bin/bash', 'LC_MONETARY': '', 'PREVLEVEL': 'N', '_': '/sbin/startproc', 'SUDO_USER': 'myuser', 'HOME': '/home/myuser', 'USERNAME': 'myuser', 'SUDO_COMMAND': '/etc/init.d/apache2 restart', 'LC_ADDRESS': '', 'SHLVL': '2', 'SUDO_UID': '1111', 'DAEMON': '/usr/sbin/httpd2-worker', 'LC_ALL': 'POSIX', 'LC_TIME': '', 'COLUMNS': '180', 'LC_IDENTIFICATION': '', 'SUDO_GID': '2500', 'LC_MESSAGES': '', 'LC_COLLATE': '', 'LC_TELEPHONE': '', 'LC_MEASUREMENT': '', 'PWD': '/srv/myapp/', 'COLORTERM': '1', 'RUNLEVEL': '3', 'LC_NAME': '', 'MAIL': '/var/mail/root', 'get_includes_done': 'true'}
[Tue Dec 16 14:48:37 2014] [error] mod_wsgi (pid=20835): Exception occurred processing WSGI script '/srv/myapp/wsgi.py'.
[Tue Dec 16 14:48:37 2014] [error] Traceback (most recent call last):
[Tue Dec 16 14:48:37 2014] [error] File "/srv/myapp/wsgi.py", line 29, in minimal_application
[Tue Dec 16 14:48:37 2014] [error]      os.stat(filename)
[Tue Dec 16 14:48:37 2014] [error] UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-7: ordinal not in range(128)

 Nikolai.

Graham Dumpleton

unread,
Dec 16, 2014, 5:50:41 PM12/16/14
to mod...@googlegroups.com
Even knowing the full set of locale related environment variables, still can't replicate on MacOS X. Definitely time to try Linux under Docker.

Graham

Graham Dumpleton

unread,
Dec 17, 2014, 5:32:05 AM12/17/14
to mod...@googlegroups.com
I have managed to replicate the problem under Linux on Docker, so obviously Linux is behaving differently to MacOS X.

Graham

Graham Dumpleton

unread,
Dec 17, 2014, 7:26:14 AM12/17/14
to mod...@googlegroups.com
Can you try using:

    lang=C.UTF-8 locale=C.UTF-8

I suspect the problem is that:

    de_DE.UTF-8

is not valid in these contexts for your specific operating system build and as a result when mod_wsgi attempts to update the locale it fails.

Right now mod_wsgi doesn't check the result and generate an error message in the logs so you wouldn't know. I will now add one though.

One way of perhaps working out if it is valid is to do is:

>>> import locale
>>> locale.setlocale(locale.LC_ALL)
'C'
>>> locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/app/.docker/python/lib/python2.7/locale.py", line 579, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
>>> locale.setlocale(locale.LC_ALL)
'C'
>>> locale.setlocale(locale.LC_ALL, 'C.UTF-8')
'C.UTF-8'
>>> locale.setlocale(locale.LC_ALL)
'C.UTF-8'

Graham

Graham Dumpleton

unread,
Dec 17, 2014, 7:54:15 PM12/17/14
to mod...@googlegroups.com
I have updated mod_wsgi to issue an error message now.


You could try that and verify you get an error message with de_DE.UTF-8, thereby confirming that was the issue.

I have noticed that especially under Docker with a trimmed down OS you are missing language packs which would allow even common en_US.UTF-8 to work.

Graham

Graham Dumpleton

unread,
Dec 19, 2014, 5:49:49 AM12/19/14
to mod...@googlegroups.com
Those changes I described were release in 4.4.2.

Graham

Nikolai Prokoschenko

unread,
Jan 4, 2015, 6:41:03 PM1/4/15
to mod...@googlegroups.com
Graham,

I wanted to give you a heads up on this issue. Effective end of 2014, I've left my project which used mod_wsgi and thus can't test anything directly anymore. However, I've instructed my staying colleagues to test your proposed solution out and give their feedback directly on this list. I suspect that prolonged Christmas holidays contributed to extended silence on their part, but I'll try to get in touch to nudge them a bit. From our previous discussion, I suspect setting LANG to "de_DE.utf8" would yield the expected result -- this is what I would like my colleagues to test out.

Thanks.

Nikolai.

Michael Radziej

unread,
Jan 9, 2015, 8:10:04 AM1/9/15
to mod...@googlegroups.com
Hi Graham,

I’m taking over from Nikolai ;)

I have installed mod_wsgi 4.4.5, sources from github download, build with opensuse build system.

On opensuse SLES11, apache is started with LC_ALL=POSIX.
The problems are caused by the filesystemencoding.

This is the apache configuration:

[code]
LogLevel debug

WSGIDaemonProcess my_application user=mir group=users lang=de_DE.UTF-8 locale=de_DE.UTF-8 processes=20 threads=1 display-name=%{GROUP} python-path=/home/mir/vpy/amm/lib/python2.6/site-packages
WSGIProcessGroup my_application

WSGIScriptAlias / /home/mir/src/encodingtest/wsgi.py

<Location />
Order allow,deny
Allow from all
</Location>
[/code]

This ist the wsgi app:

[code]
import os
import sys
import locale
import mod_wsgi


print('module: LANG', os.environ.get('LANG'))
print('module: LC_ALL', os.environ.get('LC_ALL'))
print('module: sys.getdefaultencoding()', sys.getdefaultencoding())
print('module: locale.getlocale()', locale.getlocale())
print('module: locale.getdefaultlocale()', locale.getdefaultlocale())
print('module: locale.getpreferredencoding()', locale.getpreferredencoding())
print('module: sys.getfilesystemencoding()', sys.getfilesystemencoding())


def application(environ, start_response):
print('process_group', mod_wsgi.process_group)
print('application_group', mod_wsgi.application_group)
print('LANG', os.environ.get('LANG'))
print('LC_ALL', os.environ.get('LC_ALL'))
print('sys.getdefaultencoding()', sys.getdefaultencoding())
print('locale.getlocale()', locale.getlocale())
print('locale.getdefaultlocale()', locale.getdefaultlocale())
print('locale.getpreferredencoding()', locale.getpreferredencoding())
print('sys.getfilesystemencoding()', sys.getfilesystemencoding())
print('setlocale(LC_ALL, de_DE.UTF-8)', locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8'))
print('locale.getlocale()', locale.getlocale())

[/code]

The cut-down apache logs are:

[code]
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31016): Started thread 0 in daemon process 'my_
application'.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31007): Starting process 'my_application' with uid=1000, gid=100 and threads=
1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31007): Setting lang to de_DE.UTF-8 for daemon
process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31007): Setting locale to de_DE.UTF-8 for daemo
n process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31016): Started thread 0 in daemon process 'my_
application'.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31007): Starting process 'my_application' with uid=1000, gid=100 and threads=
1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31007): Setting lang to de_DE.UTF-8 for daemon
process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31007): Setting locale to de_DE.UTF-8 for daemo
n process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31007): Started thread 0 in daemon process 'my_
application'.
[Fri Jan 09 10:05:02 2015] [info] mod_wsgi (pid=31020): Create interpreter '127.0.0.1|'.
[Fri Jan 09 10:05:02 2015] [info] mod_wsgi (pid=31020): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:05:02 2015] [info] [client ::1] mod_wsgi (pid=31020, process='my_application', application='127.0.0.1|'): Load
ing WSGI script '/home/mir/src/encodingtest/wsgi.py'.
[Fri Jan 09 10:05:02 2015] [error] ('module: LANG', 'de_DE.UTF-8')
[Fri Jan 09 10:05:02 2015] [error] ('module: LC_ALL', 'POSIX')
[Fri Jan 09 10:05:02 2015] [error] ('module: sys.getdefaultencoding()', 'ascii')
[Fri Jan 09 10:05:02 2015] [error] ('module: locale.getlocale()', ('de_DE', 'UTF8'))
[Fri Jan 09 10:05:02 2015] [error] ('module: locale.getdefaultlocale()', (None, None))
[Fri Jan 09 10:05:02 2015] [error] ('module: locale.getpreferredencoding()', 'ANSI_X3.4-1968')
[Fri Jan 09 10:05:02 2015] [error] ('module: sys.getfilesystemencoding()', 'ANSI_X3.4-1968')
[Fri Jan 09 10:05:02 2015] [error] ('process_group', 'my_application')
[Fri Jan 09 10:05:02 2015] [error] ('application_group', '127.0.0.1|')
[Fri Jan 09 10:05:02 2015] [error] ('LANG', 'de_DE.UTF-8')
[Fri Jan 09 10:05:02 2015] [error] ('LC_ALL', 'POSIX')
[Fri Jan 09 10:05:02 2015] [error] ('sys.getdefaultencoding()', 'ascii')
[Fri Jan 09 10:05:02 2015] [error] ('locale.getlocale()', ('de_DE', 'UTF8'))
[Fri Jan 09 10:05:02 2015] [error] ('locale.getdefaultlocale()', (None, None))
[Fri Jan 09 10:05:02 2015] [error] ('locale.getpreferredencoding()', 'ANSI_X3.4-1968')
[Fri Jan 09 10:05:02 2015] [error] ('sys.getfilesystemencoding()', 'ANSI_X3.4-1968')
[Fri Jan 09 10:05:02 2015] [error] ('setlocale(LC_ALL, de_DE.UTF-8)', 'de_DE.UTF-8')
[Fri Jan 09 10:05:02 2015] [error] ('locale.getlocale()', ('de_DE', 'UTF8'))
[Fri Jan 09 10:05:02 2015] [error] [client ::1] mod_wsgi (pid=31020): Exception occurred processing WSGI script '/home/mir/sr
c/encodingtest/wsgi.py'.
[Fri Jan 09 10:05:02 2015] [error] [client ::1] TypeError: 'NoneType' object is not iterable
[/code]

Full logs are:

[code]
[Fri Jan 09 10:01:59 2015] [notice] caught SIGTERM, shutting down
[Fri Jan 09 10:02:02 2015] [info] Init: Seeding PRNG with 0 bytes of entropy
[Fri Jan 09 10:02:02 2015] [info] Init: Generating temporary RSA private keys (512/1024 bits)
[Fri Jan 09 10:02:02 2015] [info] Init: Generating temporary DH parameters (512/1024 bits)
[Fri Jan 09 10:02:02 2015] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Fri Jan 09 10:02:02 2015] [info] Init: Initializing (virtual) servers for SSL
[Fri Jan 09 10:02:02 2015] [info] mod_ssl/2.2.29 compiled against Server: Apache/2.2.29, Library: OpenSSL/0.9.8j-fips
[Fri Jan 09 10:02:02 2015] [info] Init: Seeding PRNG with 0 bytes of entropy
[Fri Jan 09 10:02:02 2015] [info] Init: Generating temporary RSA private keys (512/1024 bits)
[Fri Jan 09 10:02:02 2015] [info] Init: Generating temporary DH parameters (512/1024 bits)
[Fri Jan 09 10:02:02 2015] [info] Init: Initializing (virtual) servers for SSL
[Fri Jan 09 10:02:02 2015] [info] mod_ssl/2.2.29 compiled against Server: Apache/2.2.29, Library: OpenSSL/0.9.8j-fips
[Fri Jan 09 10:02:02 2015] [warn] mod_wsgi: Compiled for Python/2.6.8.
[Fri Jan 09 10:02:02 2015] [warn] mod_wsgi: Runtime using Python/2.6.9.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(7590): mod_wsgi (pid=31003): Socket for 'my_application' is '/var/run/wsgi.31003.0.1.sock'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(7648): mod_wsgi (pid=31003): Listen backlog for socket '/var/run/wsgi.31003.0.1.sock' is '100'.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31005): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31005): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31006): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31005): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31006): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31006): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31005): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31006): Initializing Python.
[Fri Jan 09 10:02:02 2015] [notice] Apache/2.2.29 (Linux/SUSE) mod_ssl/2.2.29 OpenSSL/0.9.8j-fips mod_wsgi/4.4.5 Python/2.6.9 configured -- resuming normal operations
[Fri Jan 09 10:02:02 2015] [info] Server built: 2012-02-24 16:39:36.000000000 +0100
[Fri Jan 09 10:02:02 2015] [debug] worker.c(1774): AcceptMutex: pthread (default: pthread)
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31012): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31012): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31012): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31012): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31005): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31006): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31005): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31006): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31010): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31009): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31010): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31009): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31009): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31019): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31019): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31019): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31010): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31009): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31019): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31010): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31016): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31016): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31016): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31016): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31019): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31019): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31009): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31009): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31010): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31010): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31023): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31013): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31023): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31023): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31013): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31013): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31014): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31016): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31016): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31023): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31013): Initializing Python.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31014): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31014): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31014): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31020): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31020): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31020): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31020): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31013): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31013): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31014): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31023): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31014): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31023): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31020): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31020): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31017): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31017): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31018): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31017): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31027): Initializing Python.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31018): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31018): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31017): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31018): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31024): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31024): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31024): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31024): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31017): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31027): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31017): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31018): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31018): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31011): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31011): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31011): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31011): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31024): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31024): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31021): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31021): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31021): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31022): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31022): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31022): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31021): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31022): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31008): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31008): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31008): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31008): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31015): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31015): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31015): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31015): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31021): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31021): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31022): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31022): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31008): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31008): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31025): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31026): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31012): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31012): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31020): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31019): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31013): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31023): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31008): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31015): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31015): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31016): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31007): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9199): mod_wsgi (pid=31007): Setting lang to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(9211): mod_wsgi (pid=31007): Setting locale to de_DE.UTF-8 for daemon process group my_application.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31007): Initializing Python.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31025): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31026): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31006): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31005): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31024): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31014): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31021): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31018): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31012): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31017): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31022): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31010): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31009): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31015): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31011): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31011): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31007): Attach interpreter ''.
[Fri Jan 09 10:02:02 2015] [info] mod_wsgi (pid=31007): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31011): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:02:02 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=31007): Started thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:05:02 2015] [info] mod_wsgi (pid=31020): Create interpreter '127.0.0.1|'.
[Fri Jan 09 10:05:02 2015] [info] mod_wsgi (pid=31020): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Fri Jan 09 10:05:02 2015] [info] [client ::1] mod_wsgi (pid=31020, process='my_application', application='127.0.0.1|'): Loading WSGI script '/home/mir/src/encodingtest/wsgi.py'.
[Fri Jan 09 10:05:02 2015] [error] ('module: LANG', 'de_DE.UTF-8')
[Fri Jan 09 10:05:02 2015] [error] ('module: LC_ALL', 'POSIX')
[Fri Jan 09 10:05:02 2015] [error] ('module: sys.getdefaultencoding()', 'ascii')
[Fri Jan 09 10:05:02 2015] [error] ('module: locale.getlocale()', ('de_DE', 'UTF8'))
[Fri Jan 09 10:05:02 2015] [error] ('module: locale.getdefaultlocale()', (None, None))
[Fri Jan 09 10:05:02 2015] [error] ('module: locale.getpreferredencoding()', 'ANSI_X3.4-1968')
[Fri Jan 09 10:05:02 2015] [error] ('module: sys.getfilesystemencoding()', 'ANSI_X3.4-1968')
[Fri Jan 09 10:05:02 2015] [error] ('process_group', 'my_application')
[Fri Jan 09 10:05:02 2015] [error] ('application_group', '127.0.0.1|')
[Fri Jan 09 10:05:02 2015] [error] ('LANG', 'de_DE.UTF-8')
[Fri Jan 09 10:05:02 2015] [error] ('LC_ALL', 'POSIX')
[Fri Jan 09 10:05:02 2015] [error] ('sys.getdefaultencoding()', 'ascii')
[Fri Jan 09 10:05:02 2015] [error] ('locale.getlocale()', ('de_DE', 'UTF8'))
[Fri Jan 09 10:05:02 2015] [error] ('locale.getdefaultlocale()', (None, None))
[Fri Jan 09 10:05:02 2015] [error] ('locale.getpreferredencoding()', 'ANSI_X3.4-1968')
[Fri Jan 09 10:05:02 2015] [error] ('sys.getfilesystemencoding()', 'ANSI_X3.4-1968')
[Fri Jan 09 10:05:02 2015] [error] ('setlocale(LC_ALL, de_DE.UTF-8)', 'de_DE.UTF-8')
[Fri Jan 09 10:05:02 2015] [error] ('locale.getlocale()', ('de_DE', 'UTF8'))
[Fri Jan 09 10:05:02 2015] [error] [client ::1] mod_wsgi (pid=31020): Exception occurred processing WSGI script '/home/mir/src/encodingtest/wsgi.py'.
[Fri Jan 09 10:05:02 2015] [error] [client ::1] TypeError: 'NoneType' object is not iterable
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31010): Shutdown requested 'my_application'.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31010): Stopping process 'my_application'.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31010): Destroying interpreters.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31010): Cleanup interpreter ''.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31021): Shutdown requested 'my_application'.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31008): Shutdown requested 'my_application'.
[Fri Jan 09 10:08:17 2015] [debug] src/server/mod_wsgi.c(8184): mod_wsgi (pid=31019): Exiting thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31021): Stopping process 'my_application'.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31008): Stopping process 'my_application'.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31021): Destroying interpreters.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31008): Destroying interpreters.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31008): Cleanup interpreter ''.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31021): Cleanup interpreter ''.
[Fri Jan 09 10:08:17 2015] [debug] src/server/mod_wsgi.c(8184): mod_wsgi (pid=31016): Exiting thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:08:17 2015] [debug] src/server/mod_wsgi.c(8184): mod_wsgi (pid=31023): Exiting thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:08:17 2015] [debug] src/server/mod_wsgi.c(8184): mod_wsgi (pid=31015): Exiting thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:08:17 2015] [debug] src/server/mod_wsgi.c(8184): mod_wsgi (pid=31022): Exiting thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:08:17 2015] [debug] src/server/mod_wsgi.c(8184): mod_wsgi (pid=31017): Exiting thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:08:17 2015] [debug] src/server/mod_wsgi.c(8184): mod_wsgi (pid=31018): Exiting thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:08:17 2015] [debug] src/server/mod_wsgi.c(8184): mod_wsgi (pid=31012): Exiting thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:08:17 2015] [debug] src/server/mod_wsgi.c(8184): mod_wsgi (pid=31005): Exiting thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:08:17 2015] [debug] src/server/mod_wsgi.c(8184): mod_wsgi (pid=31010): Exiting thread 0 in daemon process 'my_application'.
[Fri Jan 09 10:08:17 2015] [info] mod_wsgi (pid=31010): Terminating Python.
[/code]

When I start Apache with LC_ALL=de_DE.UTF-8, the relevant lines look like this:

[code]
Fri Jan 09 10:38:33 2015] [error] ('module: LANG', 'de_DE.UTF-8')
[Fri Jan 09 10:38:33 2015] [error] ('module: LC_ALL', 'de_DE.UTF-8')
[Fri Jan 09 10:38:33 2015] [error] ('module: sys.getdefaultencoding()', 'ascii')
[Fri Jan 09 10:38:33 2015] [error] ('module: locale.getlocale()', ('de_DE', 'UTF8'))
[Fri Jan 09 10:38:33 2015] [error] ('module: locale.getdefaultlocale()', ('de_DE', 'UTF8'))
[Fri Jan 09 10:38:33 2015] [error] ('module: locale.getpreferredencoding()', 'UTF-8')
[Fri Jan 09 10:38:33 2015] [error] ('module: sys.getfilesystemencoding()', 'UTF-8')
[Fri Jan 09 10:38:33 2015] [error] ('process_group', 'my_application')
[Fri Jan 09 10:38:33 2015] [error] ('application_group', '127.0.0.1|')
[Fri Jan 09 10:38:33 2015] [error] ('LANG', 'de_DE.UTF-8')
[Fri Jan 09 10:38:33 2015] [error] ('LC_ALL', 'de_DE.UTF-8')
[Fri Jan 09 10:38:33 2015] [error] ('sys.getdefaultencoding()', 'ascii')
[Fri Jan 09 10:38:33 2015] [error] ('locale.getlocale()', ('de_DE', 'UTF8'))
[Fri Jan 09 10:38:33 2015] [error] ('locale.getdefaultlocale()', ('de_DE', 'UTF8'))
[Fri Jan 09 10:38:33 2015] [error] ('locale.getpreferredencoding()', 'UTF-8')
[Fri Jan 09 10:38:33 2015] [error] ('sys.getfilesystemencoding()', 'UTF-8')
[Fri Jan 09 10:38:33 2015] [error] ('setlocale(LC_ALL, de_DE.UTF-8)', 'de_DE.UTF-8')
[Fri Jan 09 10:38:33 2015] [error] ('locale.getlocale()', ('de_DE', 'UTF8'))
[Fri Jan 09 10:38:33 2015] [error] [client ::1] mod_wsgi (pid=5493): Exception occurred processing WSGI script '/home/mir/src/encodingtest/wsgi.py'.
[Fri Jan 09 10:38:33 2015] [error] [client ::1] TypeError: 'NoneType' object is not iterable
[/code]

Michael Radziej

unread,
Jan 9, 2015, 9:33:24 AM1/9/15
to mod...@googlegroups.com
modwsgi calls setlocale in response to the options 'lang' or 'locale'.
This changes the effective locale, but not the corresponding environment variables.

When python initializes, it stores the current locale away, then calls setlocale(LC_ALL, ""), which sets the locale according to the environment (i.e. LC_ALL=POSIX). Then FileSystemDefaultEncoding is set to the effective charset encoding, i.e, ASCII (same as ANSI_X3.4-1968). (see python sources,Python/pythonrun.c, Py_InitializeEx()) Then it restores the locale.

Is it possible to set the environment and not only the locale? This should result in the intended filesystemencoding.

Graham Dumpleton

unread,
Jan 10, 2015, 7:27:55 PM1/10/15
to mod...@googlegroups.com
Lets try again then.

Can you test with:

https://github.com/GrahamDumpleton/mod_wsgi/archive/develop.tar.gz

Thanks.

Graham

Michael Radziej

unread,
Jan 12, 2015, 5:14:22 AM1/12/15
to mod...@googlegroups.com

[Mon Jan 12 10:55:10 2015] [info] mod_wsgi (pid=16774): Starting process 'my_application' with uid=1000, gid=100 and threads=1.
[Mon Jan 12 10:55:10 2015] [debug] src/server/mod_wsgi.c(9212): mod_wsgi (pid=16774): Setting locale to de_DE.UTF-8 for daemon proce
ss group my_application.
[Mon Jan 12 10:55:10 2015] [info] mod_wsgi (pid=16774): Initializing Python.
[Mon Jan 12 10:55:10 2015] [notice] Apache/2.2.29 (Linux/SUSE) mod_ssl/2.2.29 OpenSSL/0.9.8j-fips mod_wsgi/4.4.6 Python/2.6.9 config
ured -- resuming normal operations
[Mon Jan 12 10:55:10 2015] [info] Server built: 2012-02-24 16:39:36.000000000 +0100
[Mon Jan 12 10:55:10 2015] [debug] worker.c(1774): AcceptMutex: pthread (default: pthread)
[Mon Jan 12 10:55:10 2015] [info] mod_wsgi (pid=16774): Attach interpreter ''.
[Mon Jan 12 10:55:10 2015] [info] mod_wsgi (pid=16774): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Mon Jan 12 10:55:10 2015] [debug] src/server/mod_wsgi.c(8203): mod_wsgi (pid=16774): Started thread 0 in daemon process 'my_applica
tion'.
[Mon Jan 12 10:55:18 2015] [info] mod_wsgi (pid=16774): Create interpreter '127.0.0.1|'.
[Mon Jan 12 10:55:18 2015] [info] mod_wsgi (pid=16774): Adding '/home/mir/vpy/amm/lib/python2.6/site-packages' to path.
[Mon Jan 12 10:55:18 2015] [info] [client ::1] mod_wsgi (pid=16774, process='my_application', application='127.0.0.1|'): Loading WSG
I script '/home/mir/src/encodingtest/wsgi.py'.
[Mon Jan 12 10:55:18 2015] [error] ('module: LANG', 'POSIX')
[Mon Jan 12 10:55:18 2015] [error] ('module: LC_ALL', 'de_DE.UTF-8')
[Mon Jan 12 10:55:18 2015] [error] ('module: sys.getdefaultencoding()', 'ascii')
[Mon Jan 12 10:55:18 2015] [error] ('module: locale.getlocale()', ('de_DE', 'UTF8'))
[Mon Jan 12 10:55:18 2015] [error] ('module: locale.getdefaultlocale()', ('de_DE', 'UTF8'))
[Mon Jan 12 10:55:18 2015] [error] ('module: locale.getpreferredencoding()', 'UTF-8')
[Mon Jan 12 10:55:18 2015] [error] ('module: sys.getfilesystemencoding()', 'UTF-8')
[Mon Jan 12 10:55:18 2015] [error] ('process_group', 'my_application')
[Mon Jan 12 10:55:18 2015] [error] ('application_group', '127.0.0.1|')
[Mon Jan 12 10:55:18 2015] [error] ('LANG', 'POSIX')
[Mon Jan 12 10:55:18 2015] [error] ('LC_ALL', 'de_DE.UTF-8')
[Mon Jan 12 10:55:18 2015] [error] ('sys.getdefaultencoding()', 'ascii')
[Mon Jan 12 10:55:18 2015] [error] ('locale.getlocale()', ('de_DE', 'UTF8'))
[Mon Jan 12 10:55:18 2015] [error] ('locale.getdefaultlocale()', ('de_DE', 'UTF8'))
[Mon Jan 12 10:55:18 2015] [error] ('locale.getpreferredencoding()', 'UTF-8')
[Mon Jan 12 10:55:18 2015] [error] ('sys.getfilesystemencoding()', 'UTF-8')
[Mon Jan 12 10:55:18 2015] [error] ('setlocale(LC_ALL, de_DE.UTF-8)', 'de_DE.UTF-8')
[Mon Jan 12 10:55:18 2015] [error] ('locale.getlocale()', ('de_DE', 'UTF8'))
[Mon Jan 12 10:55:18 2015] [error] [client ::1] mod_wsgi (pid=16774): Exception occurred processing WSGI script '/home/mir/src/encod
ingtest/wsgi.py'.
[Mon Jan 12 10:55:18 2015] [error] [client ::1] TypeError: 'NoneType' object is not iterable

Michael Radziej

unread,
Jan 12, 2015, 5:27:11 AM1/12/15
to mod...@googlegroups.com
So, it works! Are you going to create a new release?

Graham Dumpleton

unread,
Jan 12, 2015, 5:32:36 AM1/12/15
to mod...@googlegroups.com
I will be creating a release quite soon. I thought about doing a release tonight, but was lacking sufficient motivation and decided to try and complete some normal work stuff instead. So possibly tomorrow.

Michael Radziej

unread,
Jan 12, 2015, 8:44:45 AM1/12/15
to mod...@googlegroups.com
Tomorrow night is still great!

Graham Dumpleton

unread,
Jan 12, 2015, 7:45:45 PM1/12/15
to mod...@googlegroups.com

On 13/01/2015, at 12:44 AM, Michael Radziej <michael...@googlemail.com> wrote:

> Tomorrow night is still great!

No promises unfortunately.

Various stuff is blowing up at the moment which requires me to implement some hacks in mod_wsgi to work around some changes happening in Apache real soon now. Turning out to be tricker than thought it might be. :-(

Graham

Graham Dumpleton

unread,
Jan 16, 2015, 5:39:15 AM1/16/15
to mod...@googlegroups.com
Version 4.4.6 was released yesterday. Can you give it a try now.

Michael Radziej

unread,
Jan 16, 2015, 1:17:50 PM1/16/15
to mod...@googlegroups.com
On my dev system it works. The intermediate package crashed in a testing environment. We're going to try 4.4.6 there soon.

Graham Dumpleton

unread,
Jan 16, 2015, 3:41:13 PM1/16/15
to mod...@googlegroups.com

On 17/01/2015, at 5:17 AM, Michael Radziej <michael...@googlemail.com> wrote:

> On my dev system it works. The intermediate package crashed in a testing environment. We're going to try 4.4.6 there soon.


Make sure you have read:

http://blog.dscpl.com.au/2015/01/important-modwsgi-information-about.html

The changes needed to handle httpd 2.2.29 were only added right when mod_wsgi 4.4.6 was released.

So if by intermediate you mean slightly earlier copy out of git repo, that blog post explains why it crashed.

Down in the blog post you will find it also applies to already released httpd 2.2.29 and not just the about to be released httpd 2.4.11.

Graham

Michael Radziej

unread,
Jan 20, 2015, 2:15:40 PM1/20/15
to mod...@googlegroups.com
thanks for the heads-up, Graham! Tests with 4.4.6 look fine and the long and winding road to roll-out has started ...
Reply all
Reply to author
Forward
0 new messages