I am puzzled by this too. The error is not in web2py code. The error is in the string.py module. Also in your json example you are getting unicode both in py2 and py3 except py3 does not put the u'' in front of unicode strings because they are default.
On Thursday, 10 October 2019 18:05:55 UTC-7, Lisandro wrote: > > I've found the issue, it's not web2py related, sorry about that. > > My web2py instance has several applications running, each one is attached > to a domain. > I store a the map of domains:apps in a dictionary that I save to a .pkl > file. > Then my routes.py reads that file and loads the map of domains:apps > > I write the .pkl file like this: > > with open('map.pkl', 'wb') as file: > pickle.dump(dictionary_map, file, protocol=2) > > Notice I use protocol=2 because I want to be able to read/write the file > with python 2 and 3. > > In my routes.py I read the file like this: > > map = pickle.load(open('domains_apps.pkl', 'rb')) > > routers = dict( > BASE=dict( > default_controller='default', > default_function='index', > domains=map, > map_static=True, > exclusive_domain=True, > ) > ) > > > > However, after writing .pkl the file with python 3 and returning to python > 2, my applications fail with the error reported in my first message. The > error goes away if I replace the .pkl file with an old backup I had made > before using python 2. > > I have noticed that once the .pkl file is written with python 3, then > reading it with python 2 and 3 throws different results: > > *with python 3*: > >>> r = pickle.load(open('domains_apps.pkl', 'rb')) > >>> print(r) > {'prod.com': 'prod', 'test.com': 'test'} > > > *with python 2*: > >>> r = pickle.load(open('domains_apps.pkl', 'rb')) > >>> print(r) > {*u*'prod.com': *u*'prod', *u*'test.com': *u*'test'} > > > Notice that in python 2 reading the .pkl file (that was written with > python 3 using protocol=2) returns unicode strings. This doesn't happen in > python 3. But i'm not sure what protocol to use. > > I'll do some more tests and I'll post here whatever solution I can find. > Thanks for your time! > Regards, > Lisandro. > > > > > > El jueves, 10 de octubre de 2019, 21:21:53 (UTC-3), Dave S escribió: >> >> Delete all the .pyc files? >> >> >> /dps >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/29314194-7f4b-44cb-85a2-d9da5f5098a2%40googlegroups.com.