<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";
        mso-fareast-language:EN-GB;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Hi Billy,<o:p></o:p></span></a></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Thanks for your mail.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">As usual, it’s $insertYear and unicode is still not a solved problem :(<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">I ran into UnicodeEncode/DecodeErrors, but I am now happy that your change only exposed underlying issues in my code (outside of the cctbx/dials/xia2 repositories).
 I have sprinkled some forced UTF-8 encoding on top, and everything appears to be working fine now.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">As to the changed output, that for example includes default wget output where it puts the file it writes to disk in ``quotes’’, and they observe the LC_ALL
 encoding. Fortunately enough we don’t really care about fancy formatting, so this is not a real problem.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">-Markus<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Dr Markus Gerstel MBCS<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Postdoctoral Research Associate<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Tel: &#43;44 1235 778698<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Diamond Light Source Ltd.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Diamond House<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Harwell Science &amp; Innovation Campus<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Didcot<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Oxfordshire<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">OX11 0DE<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> cctbxbb-bounces@phenix-online.org [mailto:cctbxbb-bounces@phenix-online.org]
<b>On Behalf Of </b>Billy Poon<br>
<b>Sent:</b> 08 September 2016 19:45<br>
<b>To:</b> cctbx mailing list<br>
<b>Cc:</b> bkpoon@users.sourceforge.net<br>
<b>Subject:</b> Re: [cctbxbb] [Cctbx-cvs] SF.net SVN: cctbx:[25333] trunk/libtbx/env_config.py<o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal">Hi Markus,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">There is an issue with non-ASCII paths (unicode type) and basic Python functions if the locale (like 'C') does not support UTF-8. Without UTF-8 support, these functions try to convert the unicode type into a str type with the 'ascii' encoding,
 which triggers a UnicodeEncodeError. I attached a script that tests it. The unicode path should fail for libtbx.python before my change and pass for after my change. Or change the LC_ALL setting in the build/bin/libtbx.python dispatcher (if the en_US locale
 is available, en_US will fail, en_US.UTF-8 will work).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">An additional wrinkle is that LC_ALL=C works fine on my mac (OS X 10.10.5). Also, there is a &quot;C.UTF-8&quot; locale on Ubuntu, but not on CentOS.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Basically, to support non-ASCII paths (unicode type) in basic Python functions, any locale with UTF-8 or utf8 will work. The en_US part is not that important.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">What are the errors that you get? I ran the regression tests for dials (libtbx.run_tests_parallel module=dials) and dials_regression (module=dials_regression) and everything passes except for one test in dials_regression (dials_regression/test.py).
 But the error seems to be about a goniometer object. Do you have the en_US locale installed?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Right now, I'm just checking if LC_ALL is set in the user environment and using that if it has the extra UTF-8 part. I can also check the LANG environment variable. That might be work better for users that do not have the en_US locale installed.<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">--<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.5pt">Billy K. Poon</span><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal">Research Scientist, Molecular Biophysics and Integrated Bioimaging<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Lawrence Berkeley National Laboratory<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">1 Cyclotron Road, M/S 33R0345<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Berkeley, CA 94720<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Tel: (510) 486-5709<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Fax: (510) 486-5909<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Web:&nbsp;<a href="https://phenix-online.org" target="_blank">https://phenix-online.org</a><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal">On Thu, Sep 8, 2016 at 2:26 AM, &lt;<a href="mailto:markus.gerstel@diamond.ac.uk" target="_blank">markus.gerstel@diamond.ac.uk</a>&gt; wrote:<o:p></o:p></p>
<p class="MsoNormal">Hi,<br>
<br>
I just spent some time tracking software crashes to this change. Is setting the default to en_US really appropriate and what we want?<br>
In particular it affects the output of downstream, external software we run from within python.<br>
<br>
What is the unicode issue you hint at in the commit message?<br>
<br>
-Markus<br>
<br>
Dr Markus Gerstel MBCS<br>
Postdoctoral Research Associate<br>
Tel: <a href="tel:%2B44%201235%20778698">&#43;44 1235 778698</a><br>
<br>
Diamond Light Source Ltd.<br>
Diamond House<br>
Harwell Science &amp; Innovation Campus<br>
Didcot<br>
Oxfordshire<br>
OX11 0DE<br>
<br>
-----Original Message-----<br>
From: <a href="mailto:bkpoon@users.sourceforge.net">bkpoon@users.sourceforge.net</a> [mailto:<a href="mailto:bkpoon@users.sourceforge.net">bkpoon@users.sourceforge.net</a>]<br>
Sent: 07 September 2016 00:54<br>
To: <a href="mailto:cctbx-cvs@lists.sourceforge.net">cctbx-cvs@lists.sourceforge.net</a><br>
Subject: [Cctbx-cvs] SF.net SVN: cctbx:[25333] trunk/libtbx/env_config.py<br>
<br>
Revision: 25333<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://sourceforge.net/p/cctbx/code/25333" target="_blank">http://sourceforge.net/p/cctbx/code/25333</a><br>
Author:&nbsp; &nbsp;bkpoon<br>
Date:&nbsp; &nbsp; &nbsp;2016-09-06 23:54:29 &#43;0000 (Tue, 06 Sep 2016)<br>
Log Message:<br>
-----------<br>
Unicode support: set LC_ALL in dispatchers to the one in the user's environment (if available, and supports UTF-8), otherwise use the default setting of en_US.UTF-8; fixes unicode issue with python in Linux (e.g. os.path functions do not work correctly with
 unicode if LC_ALL=C<br>
<br>
Modified Paths:<br>
--------------<br>
&nbsp; &nbsp; trunk/libtbx/env_config.py<br>
<br>
Modified: trunk/libtbx/env_config.py<br>
===================================================================<br>
--- trunk/libtbx/env_config.py&nbsp; 2016-09-06 21:15:34 UTC (rev 25332)<br>
&#43;&#43;&#43; trunk/libtbx/env_config.py&nbsp; 2016-09-06 23:54:29 UTC (rev 25333)<br>
@@ -945,6 &#43;945,15 @@<br>
<br>
&nbsp; &nbsp;def write_bin_sh_dispatcher(self,<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;source_file, target_file, source_is_python_exe=False):<br>
&#43;<br>
&#43;&nbsp; &nbsp; # determine LC_ALL from environment (Python UTF-8 compatibility in Linux)<br>
&#43;&nbsp; &nbsp; LC_ALL = os.environ.get('LC_ALL')&nbsp; &nbsp; &nbsp;# user setting<br>
&#43;&nbsp; &nbsp; if (LC_ALL is not None):<br>
&#43;&nbsp; &nbsp; &nbsp; if ( ('UTF-8' not in LC_ALL) and ('utf8' not in LC_ALL) ):<br>
&#43;&nbsp; &nbsp; &nbsp; &nbsp; LC_ALL = None<br>
&#43;&nbsp; &nbsp; if (LC_ALL is None):<br>
&#43;&nbsp; &nbsp; &nbsp; LC_ALL = 'en_US.UTF-8'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # default<br>
&#43;<br>
&nbsp; &nbsp; &nbsp;f = target_file.open(&quot;w&quot;)<br>
&nbsp; &nbsp; &nbsp;if (source_file is not None):<br>
&nbsp; &nbsp; &nbsp; &nbsp;print &gt;&gt; f, '#! /bin/sh'<br>
@@ -975,7 &#43;984,7 @@<br>
&nbsp; &nbsp; &nbsp;print &gt;&gt; f, '#'<br>
&nbsp; &nbsp; &nbsp;print &gt;&gt; f, _SHELLREALPATH_CODE<br>
&nbsp; &nbsp; &nbsp;print &gt;&gt; f, 'unset PYTHONHOME'<br>
-&nbsp; &nbsp; print &gt;&gt; f, 'LC_ALL=C'<br>
&#43;&nbsp; &nbsp; print &gt;&gt; f, 'LC_ALL=' &#43; LC_ALL<br>
&nbsp; &nbsp; &nbsp;print &gt;&gt; f, 'export LC_ALL'<br>
&nbsp; &nbsp; &nbsp;print &gt;&gt; f, 'LIBTBX_BUILD=&quot;$(shellrealpath &quot;$0&quot; &amp;&amp; cd &quot;$(dirname &quot;$RESULT&quot;)/..&quot; &amp;&amp; pwd)&quot;'<br>
&nbsp; &nbsp; &nbsp;print &gt;&gt; f, 'export LIBTBX_BUILD'<br>
<br>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.<br>
<br>
<br>
------------------------------------------------------------------------------<br>
_______________________________________________<br>
Cctbx-cvs mailing list<br>
<a href="mailto:Cctbx-cvs@lists.sourceforge.net">Cctbx-cvs@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/cctbx-cvs" target="_blank">https://lists.sourceforge.net/lists/listinfo/cctbx-cvs</a><br>
<span style="color:#888888"><br>
<span class="hoenzb">--</span><br>
<span class="hoenzb">This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please
 notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.</span><br>
<span class="hoenzb">Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.</span><br>
<span class="hoenzb">Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with
 the message.</span><br>
<span class="hoenzb">Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom</span><br>
<br>
<br>
<span class="hoenzb">_______________________________________________</span><br>
<span class="hoenzb">cctbxbb mailing list</span><br>
<span class="hoenzb"><a href="mailto:cctbxbb@phenix-online.org">cctbxbb@phenix-online.org</a></span><br>
<span class="hoenzb"><a href="http://phenix-online.org/mailman/listinfo/cctbxbb" target="_blank">http://phenix-online.org/mailman/listinfo/cctbxbb</a></span></span><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>

<p align="justify">&nbsp;</p>
<p align="justify">--&nbsp;</p>
<p align="justify">This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.<br />Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. <br />Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.<br />Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom<br />&nbsp;</p></body>
</html>