On Fri, 2 Feb 2018 05:30:12 -0800 (PST)
"Edward K. Ream" <edream...@gmail.com> wrote:

> > "C:\Users\lewis\AppData\Local\Programs\Python\Python36\lib\socketserver.py",
> >  
> > line 775, in write
> >     self._sock.sendall(b)
> > TypeError: a bytes-like object is required, not 'str'
> >
> > Can you explain how to identify the str structure so I can apply
> > the change? 
> >  
> 
> The culprit appears to be that b is a str, not a bytes. 
> 
> The great thing about Python is that you have full access to most of
> the Python libs. Open socketserver.py in your favorite text editor,
> and look at the context of the error.  That may be enough.
> 
> Otherwise, you can add debugging code to socketserver.py as follows:
> 
> 1. Before changing anything, init a git repo for the folder
> containing socketserver.py.  Git will give you diffs, and you can
> revert your changes later with git checkout socketserver.py.  This is
> important protection for your system.

Going to go out on a limb here and suggest the problem may lie
in a ten year old Leo plugin that never considered Python 3, rather
than in one of the Python core libraries (@Edward ;-)  So rather than
altering Python core libraries on your system, look for str / byte
issues further up the traceback.

  File 
"/mnt/usr1/usr1_t/Package/leo/git/leo-editor/leo/plugins/pygeotag/pygeotag.py", 
line 184, in do_GET
    os.path.join(self.owner.basedir,self.staticMap[path[0]])).read())

Python is truncating the excessively long line, which in full reads:

            self.wfile.write(open(
                
os.path.join(self.owner.basedir,self.staticMap[path[0]])).read())

and should read

            self.wfile.write(g.toEncodedString(open(
                
os.path.join(self.owner.basedir,self.staticMap[path[0]])).read()))

although turns out that module doesn't know about Leo / import g, so instead:

            self.wfile.write(open(
                
os.path.join(self.owner.basedir,self.staticMap[path[0]])).read().encode('utf-8'))

I've made the necessary changes in 
https://github.com/leo-editor/leo-editor/commit/9057d5b

Thanks Lewis for reminding me about this plugin, it's kind of cool -
glad the google API part still works, had wondered if that might no
longer be supported on the google end.

Cheers -Terry


-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to