unicode errors with LeoBridge

25 views
Skip to first unread message

Kent Tenney

unread,
Apr 19, 2017, 8:56:53 AM4/19/17
to leo-editor
commit 96ac59bcb521b52df5fe66a2438808db8f2de29d

# get a controller
In [11]: lc = leoBridge.controller()

# open a file
In [11]: leof = lc.openLeoFile('pged.leo')


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-a1be1ac7f628> in <module>()
----> 1 leof = lc.openLeoFile('pged.leo')

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoBridge.py in openLeoFile(self, fileName)
    312         if self.isOpen():
    313             fileName = self.completeFileName(fileName)
--> 314             c = self.createFrame(fileName)
    315             g.app.nodeIndices.compute_last_index(c)
    316                 # New in Leo 5.1. An alternate fix for bug #130.

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoBridge.py in createFrame(self, fileName)
    346                     import time; t1 = time.time()
    347                 # This takes a long time due to imports in c.__init__
--> 348                 c = g.openWithFileName(fileName)
    349                 if trace:
    350                     t2 = time.time()

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoGlobals.py in openWithFileName(fileName, old_c, gui)
   3244     returns the commander of the newly-opened outline.
   3245     """
-> 3246     return g.app.loadManager.loadLocalFile(fileName, gui, old_c)
   3247 #@+node:ekr.20150306035851.7: *3* g.readFileIntoEncodedString
   3248 def readFileIntoEncodedString(fn, silent=False):

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoApp.py in loadLocalFile(self, fn, gui, old_c)
   2874         # Step 2: open the outline in the requested gui.
   2875         # For .leo files (and zipped .leo file) this opens the file a second time.
-> 2876         c = lm.openFileByName(fn, gui, old_c, previousSettings)
   2877         return c
   2878     #@+node:ekr.20120223062418.10394: *5* LM.openFileByName & helpers

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoApp.py in openFileByName(self, fn, gui, old_c, previousSettings)
   2911             readAtFileNodesFlag = bool(previousSettings)
   2912             # The log is not set properly here.
-> 2913             ok = lm.readOpenedLeoFile(c, fn, readAtFileNodesFlag, theFile)
   2914                 # Call c.fileCommands.openLeoFile to read the .leo file.
   2915             if not ok: return None

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoApp.py in readOpenedLeoFile(self, c, fn, readAtFileNodesFlag, theFile)
   3081         # lm = self
   3082         ok = c.fileCommands.openLeoFile(theFile, fn,
-> 3083             readAtFileNodesFlag=readAtFileNodesFlag)
   3084                 # closes file.
   3085         if ok:

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoFileCommands.py in openLeoFile(self, theFile, fileName, readAtFileNodesFlag, silent)
    831             theFile, fileName,
    832             readAtFileNodesFlag=readAtFileNodesFlag,
--> 833             silent=silent,
    834         )
    835         if ok:

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoFileCommands.py in getLeoFile(self, theFile, fileName, readAtFileNodesFlag, silent, checkOpenFiles)
    665                     # This is important for big files like LeoPy.leo.
    666                     c.redraw()
--> 667                     recoveryNode = fc.readExternalFiles(fileName)
    668         finally:
    669             if g.app.debug: g.trace('=====',

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoFileCommands.py in readExternalFiles(self, fileName)
    797         # the @thin nodes!
    798         fc.restoreDescendentAttributes()
--> 799         fc.setPositionsFromVnodes()
    800         return recoveryNode
    801     #@+node:ekr.20031218072017.1554: *6* fc.warnOnReadOnlyFiles

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoFileCommands.py in setPositionsFromVnodes(self)
   1347         use_db = g.enableDB and c.mFileName
   1348         if use_db:
-> 1349             str_pos = c.cacher.getCachedStringPosition()
   1350             if trace: g.trace('cached str_pos', str_pos)
   1351         if not str_pos:

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoCache.py in getCachedStringPosition(self)
    254         if not c:
    255             return g.internalError('no commander')
--> 256         key = self.fileKey(c.mFileName, self.globals_tag)
    257         str_pos = self.db.get('current_position_%s' % key)
    258         if trace: g.trace(c.shortFileName(), str_pos)

/opt/venv/newtdb/lib/python3.5/site-packages/leo/core/leoCache.py in fileKey(self, fileName, content, requireEncodedString)
    132         if branch and g.isUnicode(branch):
    133             branch = g.toEncodedString(branch)
--> 134         m.update(branch)
    135         m.update(fileName)
    136         m.update(content)

TypeError: Unicode-objects must be encoded before hashing

Edward K. Ream

unread,
Apr 19, 2017, 10:21:00 AM4/19/17
to leo-editor
On Wed, Apr 19, 2017 at 7:56 AM, Kent Tenney <kte...@gmail.com> wrote:
commit 96ac59bcb521b52df5fe66a2438808db8f2de29d

​Odd. The previous 078608ed2 was specifically supposed to fix this.

Edward

Edward K. Ream

unread,
Apr 25, 2017, 8:17:05 AM4/25/17
to leo-editor
Rev 023713e fixes #475 and it probably will fix this as well.

Please let me know if there are further problems.

Edward

Kent Tenney

unread,
Apr 25, 2017, 10:32:15 AM4/25/17
to leo-editor
fixed.

I was on leo_edit_pane branch, so hadn't seen the fix

checked out master
pull
confirm fix
checkout leo_edit_pane
merge master

leoBridge unicode error is fixed in leo_edit_pane

Obvious to most, but a pleasant surprise to me.
Always somewhat jarring when something works.


--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscribe@googlegroups.com.
To post to this group, send email to leo-e...@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Edward K. Ream

unread,
Apr 25, 2017, 10:40:38 AM4/25/17
to leo-editor


On Tue, Apr 25, 2017 at 9:31 AM, Kent Tenney <kte...@gmail.com> wrote:
fixed.

​Thanks for the confirmation.  These confirmation messages are really helpful to me.

Edward
Reply all
Reply to author
Forward
0 new messages