Type str doesn't support the buffer API

1,469 views
Skip to first unread message

lewis

unread,
Oct 1, 2012, 10:36:09 AM10/1/12
to leo-e...@googlegroups.com
Edward,

Here is a minor traceback when opening quickstart.leo

Leo Log Window
Leo 4.11 devel, build 5468, 2012-09-30 13:02:59
Python 3.3.0, qt version 4.8.3
Windows 6, 1, 7601, 2, Service Pack 1
reading: C:\Python33\Lib\site-packages\leo-editor\leo\doc\quickstart.leo
unexpected exception in g.importFromPath(rest)
Traceback (most recent call last):
  File "C:\Python33\Lib\site-packages\leo-editor\leo\core\leoGlobals.py", line 5689, in importFromPath
    data = imp.find_module(moduleName,[path]) # This can open the file.
  File "C:\Python33\lib\imp.py", line 203, in find_module
    package_directory = os.path.join(entry, name)
  File "C:\Python33\lib\ntpath.py", line 171, in join
    if b[:1] in seps:
TypeError: Type str doesn't support the buffer API
Can not import rest

Regards
Lewis

Edward K. Ream

unread,
Oct 2, 2012, 9:20:14 AM10/2/12
to leo-e...@googlegroups.com
On Mon, Oct 1, 2012 at 9:36 AM, lewis <lewi...@operamail.com> wrote:

> Here is a minor traceback when opening quickstart.leo

Thanks for this report. I'll fix it today.

Edward

Edward K. Ream

unread,
Oct 2, 2012, 10:26:02 AM10/2/12
to leo-e...@googlegroups.com
On Mon, Oct 1, 2012 at 9:36 AM, lewis <lewi...@operamail.com> wrote:

Strange, I have no problem opening quickstart.leo with Python 3 on the
same Windows system you have. Did you enable other plugins? Were you
executing a script?

Edward

lewis

unread,
Oct 2, 2012, 11:21:56 AM10/2/12
to leo-e...@googlegroups.com
Edward,

I'm using python 3.3.0 with the recent PyQt-Py3.3-x64-gpl-4.9.5-1.
I'll disable plugins to see if any are causing the problem.

Lewis

lewis

unread,
Oct 3, 2012, 2:16:42 AM10/3/12
to leo-e...@googlegroups.com
Edward,

I wasn't executing a script.
Further testing - I disabled these plugins:
 attrib_edit.py
 bigdash.py
 bookmarks.py
 mod_http.py
 quickMove.py
 redirect_to_log.py
 stickynotes.py
 todo.py
 word_count.py

Restart Leo and start a new file:
Leo Log Window
Leo 4.11 devel, build 5479, 2012-10-03 09:04:23

Python 3.3.0, qt version 4.8.3
Windows 6, 1, 7601, 2, Service Pack 1

Clicking into the body pane is OK, but when I type any character into the body pane the error appears:

unexpected exception in g.importFromPath(plain)

Traceback (most recent call last):
  File "C:\Python33\Lib\site-packages\leo-editor\leo\core\leoGlobals.py", line 5689, in importFromPath
    data = imp.find_module(moduleName,[path]) # This can open the file.
  File "C:\Python33\lib\imp.py", line 203, in find_module
    package_directory = os.path.join(entry, name)
  File "C:\Python33\lib\ntpath.py", line 171, in join
    if b[:1] in seps:
TypeError: Type str doesn't support the buffer API
Can not import plain

Inserting a new node does not cause the error.

Regards
Lewis

lewis

unread,
Oct 5, 2012, 7:34:28 AM10/5/12
to leo-e...@googlegroups.com
Edward,

I noticed that if I start a new leo file and copy a character or string of text into the body pane using mouse only: rt-click/ paste method there are NO errors output to the log pane.
However if I paste by the leo menu: edit>paste, the errors output to the log pane.
It's the keyboard input or leo menu activity which shows the error.

Lewis

Edward K. Ream

unread,
Oct 5, 2012, 8:20:01 AM10/5/12
to leo-e...@googlegroups.com
On Fri, Oct 5, 2012 at 6:34 AM, lewis <lewi...@operamail.com> wrote:
> Edward,
>
> I noticed that if I start a new leo file and copy a character or string of text into the body pane using mouse only: rt-click/ paste method there are NO errors output to the log pane.

This is a strange one. I notice that both import errors involve
modules in the leo/modes directory. These modules are used for syntax
coloring.

At present, I have no idea what is going on. Nor can I recreate the problem.

Edward

lewis

unread,
Oct 5, 2012, 7:16:54 PM10/5/12
to leo-e...@googlegroups.com
Edward,

Can you confirm you are using python 3.3.0 (release 29 Sept) and the latest PyQt 4.9.5-1; that's when I started seeing the errors.
It's an issue with python 3.3.0.  I just reinstalled python 3.2.3 and the errors don't appear.

Thanks
Lewis

Edward K. Ream

unread,
Oct 8, 2012, 3:03:25 PM10/8/12
to leo-e...@googlegroups.com
On Fri, Oct 5, 2012 at 6:16 PM, lewis <lewi...@operamail.com> wrote:
> Edward,
>
> Can you confirm you are using python 3.3.0 (release 29 Sept) and the latest
> PyQt 4.9.5-1; that's when I started seeing the errors.

I'm using older code.

> It's an issue with python 3.3.0. I just reinstalled python 3.2.3 and the errors don't appear.

I see. Perhaps 3.2.3 is a bit more picky about the str/bytes
distinction. I'll investigate...

Edward

redla

unread,
Nov 24, 2012, 6:22:59 PM11/24/12
to leo-e...@googlegroups.com
I am observing the same problem for several weeks too:
---
** isPython3: True
Leo 4.11 devel, build 5514, 2012-11-23 08:01:18

Python 3.3.0, qt version 4.8.3
linux
setting leoID from os.getenv('USER'): 'halir'
load dir: /usr/local/Sources/leo/leo/core
global config dir: /usr/local/Sources/leo/leo/config
home dir: /home/halir
reading settings in /usr/local/Sources/leo/leo/config/leoSettings.leo
reading settings in /home/halir/.leo/myLeoSettings.leo
reading settings in /home/halir/.leo/myLeoSettings.leo

unexpected exception in g.importFromPath(plain)
Traceback (most recent call last):

File "/usr/local/Sources/leo/leo/core/leoGlobals.py", line 5695, in importFromPath

data = imp.find_module(moduleName,[path]) # This can open the file.

File "/usr/lib/python3.3/imp.py", line 203, in find_module
package_directory = os.path.join(entry, name)

File "/usr/lib/python3.3/posixpath.py", line 92, in join
"components.") from None

TypeError: Can't mix strings and bytes in path components.

Can not import plain
---

After little investigation inside importFromPath() [in leoGlobals.py], it seems that "path" makes the problem. At least if I print both moduleName and path around line 5684, I see:
---
plain
b'/usr/local/Sources/leo/leo/modes'
---

I don't know leo internals enough to provide a proper fix but after deleting the problematic(?) line
path = g.toEncodedString(path)
the exception disappears and I see
---
plain
/usr/local/Sources/leo/leo/modes
---
as expected. Hope this helps...
Radim

Edward K. Ream

unread,
Nov 26, 2012, 10:45:29 AM11/26/12
to leo-e...@googlegroups.com
On Sat, Nov 24, 2012 at 5:22 PM, redla <radim...@gmail.com> wrote:
I am observing the same problem for several weeks too: [with Python 3.3.0]

I'll install 3.3.0 and see what happens...

Edward

Edward K. Ream

unread,
Nov 26, 2012, 10:56:25 AM11/26/12
to leo-e...@googlegroups.com

I installed 3.3.0 and the latest pyqt and now I *do* see the problem.  I'll fix it immediately.

EKR

Edward K. Ream

unread,
Nov 26, 2012, 11:12:22 AM11/26/12
to leo-e...@googlegroups.com

Done at rev 5516.  All expected unit tests pass.

Edward
Reply all
Reply to author
Forward
0 new messages