From mboxrd@z Thu Jan 1 00:00:00 1970 From: john at keeping.me.uk (John Keeping) Date: Thu, 9 Mar 2017 00:10:03 +0000 Subject: [PATCH] filter: set environment variable PYTHONIOENCODING to utf-8 In-Reply-To: References: <20170223154823.18206-1-roy@marples.name> <20170304123521.GC2102@john.keeping.me.uk> Message-ID: <20170309001002.GF2102@john.keeping.me.uk> On Wed, Mar 08, 2017 at 07:01:59PM +0000, Roy Marples wrote: > On 06/03/2017 09:14, Roy Marples wrote: > > On 04/03/2017 12:35, John Keeping wrote: > >> On Thu, Feb 23, 2017 at 03:48:23PM +0000, Roy Marples wrote: > >>> This allows different versions of Python to be used rather than > >>> forcing version specific encoding in each script. > >>> > >>> Signed-off-by: Roy Marples > >>> --- > >>> filter.c | 8 ++++++++ > >>> filters/email-gravatar.py | 3 --- > >>> filters/syntax-highlighting.py | 5 +---- > >>> 3 files changed, 9 insertions(+), 7 deletions(-) > >> > >> Neat! This definitely makes writing it easier to get it right with > >> Python filters, but having filter_env_set seems unnecessary. > >> > >> Is there a reason not to either: > >> > >> 1) set PYTHONIOENCODING unconditionally early in startup > >> > >> or > >> > >> 2) set the environment in the child after forking > > > > No reason. > > I went this approach so that it's only set once when needed, happy to > > re-base my work with either of the two above options. > > Is there anything more you want me to do here? I was hoping someone else would jump in with an opinion, but this is quite a quiet mailing list so it might take a while. Having thought about it a bit more, my vote is for moving the setenv into the child. It keeps it where it is being used and I expect most requests to hit zero or one exec filter(s) so we won't be calling setenv() multiple times (and if we do, the cost will be dwarfed by the cost of executing a new process anyway).