Repository: web2py/web2py

Issue:
After updating from 2.18.1 to 2.18.2 the session.flash messages all show as b'<message>'
**Describe the bug**
After updating from 2.18.1 to 2.18.2 the session.flsh messages all show as b'<message>'

**To Reproduce**
Just login on any app that shows session.flash. The 'Hello World' message from the welcome app uses response.flash and not session.flash and thus it does not show the problem.

**Desktop (please complete the following information):**
Windows 7 Pro x64 w/SP1 + all upgrades
Firefox 65.0.1 x64
Python 3.7.1 x86



Discussion:
It is happening in all session.flash messages, including in the admin interface.
I didn't think it would be related, but I cleared the browser cache, removed all sessions and don't use any cache from web2py. Same result.
**Desktop (please complete the following information):**

* OS: Darwin
* Browser Chrome
* Version 72
* Python 3.7.2

**Additional context**
ref:
https://groups.google.com/forum/#!topic/web2py/I0w9pyk8vF4
Similar issue occurs if you store the menu object in session. Looks fine when viewing the session with the toolbar, but the menu renders each "menu item" as "b'menu item'"
Maybe it has somethng to do with this? A prefix of 'b' or 'B' is ignored in Python 2.

In Python 3, Bytes literals are always prefixed with 'b' or 'B'; they produce an instance of the bytes type instead of the str type. They may only contain ASCII characters; bytes with a numeric value of 128 or greater must be expressed with escapes.

Python 3.x makes a clear distinction between the types:

str = '...' literals = a sequence of Unicode characters (UTF-16 or UTF-32, depending on how Python was compiled)

bytes = b'...' literals = a sequence of octets (integers between 0 and 255)
It may be that. What is strange is why that only occurred with the upgrade from 2.18.1 to 2.18.2.
There was an update around something like this: https://github.com/web2py/web2py/commit/818494d0f3f682c6d82e58b73a7b88eef5880f2e. Maybe that introduced the bug? 
Yeah, it looks like its in gluon/html.py.. will be able to have a look tomorrow
Can't seem to fix it. Appreciate other people's ideas 
Yep, giving up.. this error seems to be trickier than I an thougt..
Custom flash messages such as session.flash = 'Test' are not showing the "b" and work ok. 
All of my session.flash (custom or not) show the b prefix. Even the 'Hello World." message in the welcome app if I change from response.flash to session.flash it shows the problem.
Really strugglin with this.. I tried to change the web2py.js file in the static folder and have jquery remove the the b.. but it doesnt work.. it disables the messages completly:
		flash.text(message).replace('b', '');
Found a kludge. Copy the files compileapp.py, languages.py and utils.py from version 2.18.1. And the session.flash messages all work fine.
Could you attach the 3 files from 2.18.1 or just hge whole previous version as zip so I can also investigate more please? I don't have the old verrsion and don't know where I would get thr old files from. Thanks! 
You can download them from GitHub
[https://github.com/web2py/web2py/tree/afaf57f6daab27c5234e2a74339d9b36250f3af7](https://github.com/web2py/web2py/tree/afaf57f6daab27c5234e2a74339d9b36250f3af7)


Resolving patch:
diff --git a/gluon/languages.py b/gluon/languages.py
--- a/gluon/languages.py
+++ b/gluon/languages.py
@@ -451,7 +451,7 @@ def __mod__(self, symbols):
 
 
 def pickle_lazyT(c):
-    return str, (c.xml(),)
+    return str, (to_native(c.xml()),)
 
 copyreg.pickle(lazyT, pickle_lazyT)
 


Test patch: