Re: [frogs] [patch] convert-ly cannot deal with accented characters |
[ Thread Index |
Date Index
| More lilynet.net/frogs Archives
]
On Thu, Mar 4, 2010 at 4:48 PM, Valentin Villenave
<v.villenave@xxxxxxxxx> wrote:
> On Thu, Mar 4, 2010 at 5:41 PM, Graham Percival
> <graham@xxxxxxxxxxxxxxxxx> wrote:
>> I expect my 1st year students to go "duh, it doesn't work". You can
>> do better than them.
>
> Come on, I'm but a pianist :)
Have you *seen* some of my students?
> The problem comes from
>
> - f.write (s.encode (f.encoding or 'utf_8'))
>
> since a) the f object *doesn't have* an "encoding" property, and
> b) the s object cannot be encoded without having been decoded first.
That's the original problem, which your patch solved for some cases.
But when your patch fails for other cases, how does it fail?
> I need the second part of the variable (hence the [1]).
>
> + f.write (s
> + .decode (sys.stderr.encoding or locale.getdefaultlocale()[1])
> + .encode (f.encoding or 'utf_8'))
>
> Last time I checked, it worked. Turns out it doesn't.
Under what conditions? (hint: maybe an error message about "NoneType" ?)
Then the question is either "how can we either avoid those
conditions", or "how can we make the code do something different in
those conditions". The answer to the latter question is lab 2,
exercise 6... oh wait, sorry, you're not using my C labs (completely
rewritten by all the doc knowledge of yours truly).
You'll feel better if you solve this yourself instead of waiting for
John to fix it for you. Trust me.
- Graham
---
----
Join the Frogs!