gPodder Bug Tracker – Bug 1697
ENCODING FAIL: Exception = must be str, not bytes
Last modified: 2012-10-23 12:03:01 BST
Once I get over Bug 1696 ( https://bugs.gpodder.org/show_bug.cgi?id=1696 ) by commenting out slots or property statement, I am getting the following error:
*** ENCODING FAIL ***
Please report this to http://bugs.gpodder.org/:
args = ('\ngPodder 3.3.0 "Intermission" (2012-09-24) - http://gpodder.org/\n© 2005-2012 Thomas Perl and the gPodder Team\nLicense: GNU General Public License, version 3 or later\n\nEntering interactive shell. Type \'help\' for help.\nPress Ctrl+D (EOF) or type \'quit\' to quit.\n',)
map(convert, args) = ['\ngPodder 3.3.0 "Intermission" (2012-09-24) - http://gpodder.org/\n© 2005-2012 Thomas Perl and the gPodder Team\nLicense: GNU General Public License, version 3 or later\n\nEntering interactive shell. Type \'help\' for help.\nPress Ctrl+D (EOF) or type \'quit\' to quit.\n']
Exception = must be str, not bytes
Not sure where it is coming from; so I am having difficulty troubleshooting further
It's safe_print() in bin/gpo. This is mostly a function that does all kinds of crazy encoding-related stuff to avoid all the stupid bugs of Python 2 wrt encoding. In Python 3, we can probably have a shortcut there, and replace "safe_print" just with "print" (e.g. by writing after the "def safe_print():" block:
safe_print = print
We can do this in Python 3, because print is a normal function.
Thanks, that gets over this.
Unfortunately, safe_print is called with newline=False, which is invalid keyword in Python 3...
(In reply to comment #2)
> Thanks, that gets over this.
> Unfortunately, safe_print is called with newline=False, which is invalid
> keyword in Python 3...
In that case, we should change our safe_print() function to take end="" instead of newline=False) and modify the code accordingly. Can you implement a patch?
trying right now :)
Created attachment 744 [details]
patch for safe_print
Well, the "trivial" patch is attached.
Note, however, that this is a patch against updated gpo (that is, gpo after 2to3). Which leads me to a bigger question. How flexible you want to be with Python version detection. If there is a separate "gpo3" (3 for version of Python, not of gpo :) ) then version detection isn't necessary. But in such case you may want to clean calls to safe_print, rather have a safe_print translating such calls
If, however, you want to have one flexible file, it may be necessary to have something like
if sys.version_info >= (3, ):
extra['use_2to3'] = True
and *force* users to run setup...
My background is in PHP, where after a few years it was told "no more PHP4, upgrade to PHP5 or else" - and the community lived happily ever after! So this Python 2 vs 3 dilemma looks a little bit crazy to me. So, I'll let you decide how you want to proceed
For now, we want to (have to) support Python 2.x still, as the Gtk UI doesn't support Python 3 yet. We want to keep the codebase compatible with both versions of Python (2 and 3), so I've fixed this in a similar way to your patch:
Please test if this works and doesn't cause problems when using 2to3.