<div dir="ltr">Hi Markus,<div><br></div><div>There is an issue with non-ASCII paths (unicode type) and basic Python functions if the locale (like &#39;C&#39;) does not support UTF-8. Without UTF-8 support, these functions try to convert the unicode type into a str type with the &#39;ascii&#39; 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).</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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?</div><div><br></div><div>Right now, I&#39;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.</div>







</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><div>--</div><div><span style="font-size:12.8000001907349px">Billy K. Poon</span><br></div></div><div>Research Scientist, Molecular Biophysics and Integrated Bioimaging</div><div>Lawrence Berkeley National Laboratory</div><div>1 Cyclotron Road, M/S 33R0345</div><div>Berkeley, CA 94720</div><div>Tel: (510) 486-5709</div><div>Fax: (510) 486-5909</div><div>Web: <a href="https://phenix-online.org" target="_blank">https://phenix-online.org</a></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Sep 8, 2016 at 2:26 AM,  <span dir="ltr">&lt;<a href="mailto:markus.gerstel@diamond.ac.uk" target="_blank">markus.gerstel@diamond.ac.uk</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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" value="+441235778698">+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.<wbr>sourceforge.net</a>]<br>
Sent: 07 September 2016 00:54<br>
To: <a href="mailto:cctbx-cvs@lists.sourceforge.net">cctbx-cvs@lists.sourceforge.<wbr>net</a><br>
Subject: [Cctbx-cvs] SF.net SVN: cctbx:[25333] trunk/libtbx/env_config.py<br>
<br>
Revision: 25333<br>
          <a href="http://sourceforge.net/p/cctbx/code/25333" rel="noreferrer" target="_blank">http://sourceforge.net/p/<wbr>cctbx/code/25333</a><br>
Author:   bkpoon<br>
Date:     2016-09-06 23:54:29 +0000 (Tue, 06 Sep 2016)<br>
Log Message:<br>
-----------<br>
Unicode support: set LC_ALL in dispatchers to the one in the user&#39;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>
    trunk/libtbx/env_config.py<br>
<br>
Modified: trunk/libtbx/env_config.py<br>
==============================<wbr>==============================<wbr>=======<br>
--- trunk/libtbx/env_config.py  2016-09-06 21:15:34 UTC (rev 25332)<br>
+++ trunk/libtbx/env_config.py  2016-09-06 23:54:29 UTC (rev 25333)<br>
@@ -945,6 +945,15 @@<br>
<br>
   def write_bin_sh_dispatcher(self,<br>
         source_file, target_file, source_is_python_exe=False):<br>
+<br>
+    # determine LC_ALL from environment (Python UTF-8 compatibility in Linux)<br>
+    LC_ALL = os.environ.get(&#39;LC_ALL&#39;)     # user setting<br>
+    if (LC_ALL is not None):<br>
+      if ( (&#39;UTF-8&#39; not in LC_ALL) and (&#39;utf8&#39; not in LC_ALL) ):<br>
+        LC_ALL = None<br>
+    if (LC_ALL is None):<br>
+      LC_ALL = &#39;en_US.UTF-8&#39;              # default<br>
+<br>
     f = target_file.open(&quot;w&quot;)<br>
     if (source_file is not None):<br>
       print &gt;&gt; f, &#39;#! /bin/sh&#39;<br>
@@ -975,7 +984,7 @@<br>
     print &gt;&gt; f, &#39;#&#39;<br>
     print &gt;&gt; f, _SHELLREALPATH_CODE<br>
     print &gt;&gt; f, &#39;unset PYTHONHOME&#39;<br>
-    print &gt;&gt; f, &#39;LC_ALL=C&#39;<br>
+    print &gt;&gt; f, &#39;LC_ALL=&#39; + LC_ALL<br>
     print &gt;&gt; f, &#39;export LC_ALL&#39;<br>
     print &gt;&gt; f, &#39;LIBTBX_BUILD=&quot;$(shellrealpath &quot;$0&quot; &amp;&amp; cd &quot;$(dirname &quot;$RESULT&quot;)/..&quot; &amp;&amp; pwd)&quot;&#39;<br>
     print &gt;&gt; f, &#39;export LIBTBX_BUILD&#39;<br>
<br>
This was sent by the SourceForge.net collaborative development platform, the world&#39;s largest Open Source development site.<br>
<br>
<br>
------------------------------<wbr>------------------------------<wbr>------------------<br>
______________________________<wbr>_________________<br>
Cctbx-cvs mailing list<br>
<a href="mailto:Cctbx-cvs@lists.sourceforge.net">Cctbx-cvs@lists.sourceforge.<wbr>net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/cctbx-cvs" rel="noreferrer" target="_blank">https://lists.sourceforge.net/<wbr>lists/listinfo/cctbx-cvs</a><br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
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>
<br>
<br>
______________________________<wbr>_________________<br>
cctbxbb mailing list<br>
<a href="mailto:cctbxbb@phenix-online.org">cctbxbb@phenix-online.org</a><br>
<a href="http://phenix-online.org/mailman/listinfo/cctbxbb" rel="noreferrer" target="_blank">http://phenix-online.org/<wbr>mailman/listinfo/cctbxbb</a><br>
</font></span></blockquote></div><br></div>