<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal"><p dir="auto">Hi Chris, </p>
<p dir="auto">We (they) are fixing it, though it quickly got out of my depth…  If you had any suggestions for them, I’m sure they would listen.  They are actively interested in addressing this.</p>
<p dir="auto"><a href="https://github.com/nucleic/kiwi/pull/40">https://github.com/nucleic/kiwi/pull/40</a></p>
<p dir="auto">Thanks!   Jody</p>
<br><br><p dir="auto">On 11 Sep 2017, at 13:56, Chris Barker wrote:</p>
</div>
<blockquote style="border-left:2px solid #5855D5; color:#5855D5; margin:0 0 5px; padding-left:5px"><div id="EF80DF4F-5A38-4796-BA80-881B9C2992E6"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Sep 8, 2017 at 2:11 PM, Jody Klymak <span dir="ltr"><<a href="mailto:jklymak@uvic.ca" target="_blank">jklymak@uvic.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>




<div>
<div style="font-family:sans-serif"><span class="gmail-"><div style="white-space:normal">
<p dir="auto">Unfortunately, that is the problem.  <code>kiwi</code>, which is written in CPP, has a check for python version:<br></p></div></span><div style="white-space:normal">

<pre style="border:thin solid gray;margin-left:15px;margin-right:15px;max-width:90vw;overflow-x:auto;padding:5px"><code>#if PY_MAJOR_VERSION >= 3
#define FROM_STRING PyUnicode_FromString
#else
#define FROM_STRING PyString_FromString
#endif
</code></pre>

<p dir="auto"></p></div></div></div></blockquote><div>ouch! IMHO, they made a major mistake here -- they should have used Unicode in both versions, and cast a py2 string to unicode if need be. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:sans-serif"><div style="white-space:normal"><p dir="auto">So it can handle Unicode, but has no way to know it <em>should</em> handle Unicode if we are using python 2.7 and <code>unicode_literals</code>. </p></div></div></div></blockquote><div><br></div><div>actually, this looks like it can't handle unicode in the CPP code under py2 at all :-( </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:sans-serif"><div style="white-space:normal"><p dir="auto"> I’ve opened <a href="https://github.com/nucleic/kiwi/issues/39" target="_blank">an issue with them,</a> though of course if someone here had expertise in this it’d be very helpful.  Worst case scenario I can just cast every call to <code>str</code>, it just makes the code a bit of a mess.</p></div></div></div></blockquote><div>unless they change the cpp, I think you'll have to do that. Then prepare yourself for mysterious encoding errors to pop up later on ....</div><div><br></div><div>:-(</div><div><br></div><div>-CHB</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:sans-serif"><div style="white-space:normal"><blockquote style="border-left:2px solid rgb(88,85,213);color:rgb(88,85,213);margin:0px 0px 5px;padding-left:5px"><span class="gmail-"><p dir="auto">Now, whether or not this would fix your problem or not, I haven't a clue.<br></p></span></blockquote></div></div></div></blockquote><div>the error is:</div><div><span style="color:rgb(0,175,204);font-family:sans-serif">TypeError: Expected object of typefloat,</span><br style="color:rgb(0,175,204);font-family:sans-serif"><span style="color:rgb(0,175,204);font-family:sans-serif">int, or long. Got object of type unicode instead.</span><br></div><div> </div><div>are you sure this is a unicode instead of string problem? MAybe you need to call float() or int() on the value before passing it in.</div><div><br></div><div>-CHB</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:sans-serif"><div style="white-space:normal"><blockquote style="border-left:2px solid rgb(88,85,213);color:rgb(88,85,213);margin:0px 0px 5px;padding-left:5px"><blockquote style="border-left:2px solid rgb(0,175,204);color:rgb(0,175,204);margin:0px 0px 5px;padding-left:5px"><p dir="auto"><span class="gmail-">
Am I supposed to put # -*- coding: utf-8 -*- at the top of every source<br>
that might create a string that calls these functions?</span></p></blockquote></blockquote></div></div></div></blockquote><div>that will make no difference. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:sans-serif"><div style="white-space:normal"><blockquote style="border-left:2px solid rgb(88,85,213);color:rgb(88,85,213);margin:0px 0px 5px;padding-left:5px"><blockquote style="border-left:2px solid rgb(0,175,204);color:rgb(0,175,204);margin:0px 0px 5px;padding-left:5px"><p dir="auto"><span class="gmail-"> Or should I convert<br>
the string somehow in my wrappers before passing down?</span></p></blockquote></blockquote></div></div></div></blockquote><div>yeah, probably. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:sans-serif"><div style="white-space:normal"><blockquote style="border-left:2px solid rgb(88,85,213);color:rgb(88,85,213);margin:0px 0px 5px;padding-left:5px"><blockquote style="border-left:2px solid rgb(0,175,204);color:rgb(0,175,204);margin:0px 0px 5px;padding-left:5px"><p dir="auto"><span class="gmail-"> Or does from<br>
__future__ import unicode_literals do this?<br></span></p></blockquote></blockquote></div></div></div></blockquote><div>what that does is make text literals, like:</div><div><br></div><div>"this is some  text" </div><div><br></div><div>a unicode object, rather than a py2string object -- but if the string comes from somewhere else, it makes no difference.</div><div><br></div><div>But if that IS in the source, then you will get a lot more unicode objects getting passed around.</div><div><br></div><div>-CHB</div><div><br></div><div>-- <br></div></div><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div></div></blockquote>
<div style="white-space:normal"><blockquote style="border-left:2px solid #5855D5; color:#5855D5; margin:0 0 5px; padding-left:5px">
</blockquote></div>
</div>
</body>
</html>