file.write() of non-ASCII characters differs in Interpreted Python than in script run

RAH rene.heymans at
Wed Aug 26 11:12:05 CEST 2015

Dear Chris,
I can confirm it is Python 3. Here is the line from the Apache2 log:

[Wed Aug 26 10:28:01.508194 2015] [mpm_worker:notice] [pid 1120:tid 3074398848] AH00292: Apache/2.4.7 (Ubuntu) OpenSSL/1.0.1f mod_wsgi/4.4.13 Python/3.4.0 configured -- resuming normal operations

As a matter of fact, I connect to the same machine that runs Apache2/mod_wsgi/Python via PuTTY and when I open the Python interpreter it responds:

> Python 3.4.0 (default, Jun 19 2015, 14:18:46)
> [GCC 4.8.2] on linux
> Type "help", "copyright", "credits" or "license" for more information.

Hence exactly the same Python 3.4.0 version.

By the way my whole installation is defaulted to UTF-8:

HTML: 	     <head><meta charset="utf-8"></head>
Javascript:  <script type="text/javascript" charset="UTF-8">
PuTTY:       >Translation>Character set translation>Remote character set>UTF-8
Python code: # -*- coding: utf-8 -*-
Linux:       $ echo $LANG ---> en_US.UTF-8

Finally, I also checked the coding of the `request_body` as written in the binary file (`logbytes`) and `Ç` is indeed coded as C387 (hex) or `é` is correctly written as C3A9 (hex).

Thank you Chris,

More information about the Python-list mailing list