For my own learning I have used an example to show that I can change a str 
type to bytes with
b = g.toEncodedString(my_string)
and confirmed the change with the type() function. 

But from the log I can't recognise what the str is that needs changing in 
line 184:
  [snip]
  File "N:\git\leo-editor\leo\plugins\pygeotag\pygeotag.py", line 184, in 
do_GET
    os.path.join(self.owner.basedir,self.staticMap[path[0]])).read())
  File 
"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? 

Regards
Lewis


On Saturday, January 27, 2018 at 12:25:41 AM UTC+11, Edward K. Ream wrote:
>
> In Leo, the best way (usually) to convert from a string to bytes type is 
> with:
>
>   b = g.toEncodedString(aString)
>
> This handles differences between python 2 and 3, and handles error 
> checking when aString.encode throws an exception. It also works when 
> aString is already a bytes object.
>
> Similarly, g.toUnicode(obj) is the best way to convert from bytes to 
> unicode.
>
>

-- 
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