Viktor, please test rev 5083: it attempts to fix rst3 unicode bug

16 views
Skip to first unread message

Edward K. Ream

unread,
Mar 7, 2012, 8:27:53 AM3/7/12
to leo-editor
Rev 5083 attempts to fix bug 923301: Unicode error when executing
'rst3' command

https://bugs.launchpad.net/leo-editor/+bug/923301

I've marked this bug as closed. Feel free to reopen if necessary.

A few simple tests pass, including a new unit test, but I have little
confidence in the fix.

Edward

Viktor Ransmayr

unread,
Mar 12, 2012, 9:51:35 AM3/12/12
to leo-editor
Hello Edward,

my reply took a bit longer since I was completely offline for 5 days.
I have updated my version of Leo to the latest revision 5126.

When I run the 'rst3' command on *any* outline I get the following log

<log>

D:\Users\Viktor Ransmayr\Documents>leo ./BR-2012-01-28.leo

** isPython3: True
Leo 4.9.1 devel, build 5126, 2012-03-12 14:36:27
Python 3.2.2, qt version 4.8.0
Windows 6, 1, 7601, 2, Service Pack 1
reading settings in D:\Branches\leo-editor\leo\config\leoSettings.leo
reading settings in D:\Users\Viktor Ransmayr\.leo\myLeoSettings.leo
reading settings in D:\Users\Viktor Ransmayr\Documents
\BR-2012-01-28.leo
Traceback (most recent call last):
File "D:\Branches\leo-editor\leo\plugins\qtGui.py", line 8657, in
eventFilter
ret = k.masterKeyHandler(event)
File "D:\Branches\leo-editor\leo\core\leoKeys.py", line 2896, in
masterKeyHandler
done,val = k.doMode(event,state,stroke)
File "D:\Branches\leo-editor\leo\core\leoKeys.py", line 2974, in
doMode
val = k.callStateFunction(event) # Calls end-command.
File "D:\Branches\leo-editor\leo\core\leoKeys.py", line 2948, in
callStateFunction
val = k.state.handler(event)
File "D:\Branches\leo-editor\leo\core\leoKeys.py", line 2036, in
fullCommand
k.callAltXFunction(k.mb_event)
File "D:\Branches\leo-editor\leo\core\leoKeys.py", line 2082, in
callAltXFunction
func(event)
File "D:\Branches\leo-editor\leo\core\leoRst.py", line 473, in rst3
self.processTopTree(self.c.p)
File "D:\Branches\leo-editor\leo\core\leoRst.py", line 483, in
processTopTree

self.processTree(p,ext=None,toString=False,justOneFile=justOneFile)
File "D:\Branches\leo-editor\leo\core\leoRst.py", line 511, in
processTree

self.write_rst_tree(p,ext,fn,toString=toString,justOneFile=justOneFile)
File "D:\Branches\leo-editor\leo\core\leoRst.py", line 561, in
write_rst_tree

self.write_files(ext,fn,callDocutils,toString,writeIntermediateFile)
File "D:\Branches\leo-editor\leo\core\leoRst.py", line 1755, in
write_files
f.write(s)
TypeError: must be str, not bytes

</log>

and the target document is not created.

With kind regards,

Viktor

Edward K. Ream

unread,
Mar 12, 2012, 9:55:52 AM3/12/12
to leo-e...@googlegroups.com
On Mon, Mar 12, 2012 at 8:51 AM, Viktor Ransmayr
<viktor....@gmail.com> wrote:

> When I run the 'rst3' command on *any* outline I get the following log

> self.write_files(ext,fn,callDocutils,toString,writeIntermediateFile)


>  File "D:\Branches\leo-editor\leo\core\leoRst.py", line 1755, in
> write_files
>    f.write(s)
> TypeError: must be str, not bytes

Thanks. I'll attempt a fix today.

Edward

Edward K. Ream

unread,
Mar 12, 2012, 5:32:56 PM3/12/12
to leo-e...@googlegroups.com
On Mon, Mar 12, 2012 at 8:55 AM, Edward K. Ream <edre...@gmail.com> wrote:
> On Mon, Mar 12, 2012 at 8:51 AM, Viktor Ransmayr
> <viktor....@gmail.com> wrote:
>
>> When I run the 'rst3' command on *any* outline I get the following log

> Thanks.  I'll attempt a fix today.

Please test rev 5133 and let me know how it works for you. Rather
than attempting a test of the actual failing code, I created a
stand-alone test of similar logic. This test passes for Python 2.x
and 3.x. I then copied the test code into place.

Edward

Viktor Ransmayr

unread,
Mar 13, 2012, 5:30:15 AM3/13/12
to leo-e...@googlegroups.com
Hello Edward,
Just a quick confirmation that this revision fixes this problem also
for me. - Thanks!

Viktor

Message has been deleted

Edward K. Ream

unread,
Mar 13, 2012, 8:42:34 AM3/13/12
to leo-e...@googlegroups.com
On Tue, Mar 13, 2012 at 4:30 AM, Viktor Ransmayr
<viktor....@gmail.com> wrote:

> Just a quick confirmation that this revision fixes this problem also
> for me. - Thanks!

Oh good. I'll remember this fix: completely different
unicode-related code is required depending on whether a file is opened
in "w" or "wb" mode.

Edward

Reply all
Reply to author
Forward
0 new messages