apinho <jaap...@sapo.pt>: Feb 06 12:09PM -0800
Hi,
I was using an web2py app on :
Windows Server 2016
2.18.2-stable+timestamp.2019.02.26.06.11.06
(Running on Rocket 1.2.6, Python 2.7.9)
Now, I'm using :
Centos 7
2.27.1-stable+timestamp.2023.11.15.23.33.20
(Running on Unknown, Python 2.7.5)
I'm having lots of encode problems.
Take this sample code :
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
def myFunction():
my_unicode = 'Eusébio'
my_goals = db.executesql("SELECT * FROM goals WHERE scorer =
'{}';".format(my_unicode), as_dict = True)
return dict(my_goals)
Calling /myapp/test/myFunction works fine on my Windows machine, but fails
on Centos 7 :
Traceback (most recent call last):
File "<obfuscated>/web2py/gluon/restricted.py", line 219, in restricted
exec(ccode, environment)
File " <obfuscated> /web2py/applications/ <obfuscated> /controllers/test.py",
line 7, in <module>
File " <obfuscated> /web2py/gluon/globals.py", line 463, in <lambda>
self._caller = lambda f: f()
File " <obfuscated> /web2py/applications/ <obfuscated> /controllers/test.py",
line 5, in myFunction
my_goals = db.executesql("SELECT * FROM goals WHERE scorer =
'{}';".format(my_unicode), as_dict = True)
File " <obfuscated> /web2py/gluon/packages/dal/pydal/base.py", line 882,
in executesql
adapter.execute(query)
File " <obfuscated> /web2py/gluon/packages/dal/pydal/adapters/__init__.py",
line 70, in wrap
return f(*args, **kwargs)
File " <obfuscated> /web2py/gluon/packages/dal/pydal/adapters/mssql.py",
line 128, in execute
args[0] = to_unicode(args[0])
File " <obfuscated> /web2py/gluon/packages/dal/pydal/_compat.py", line
173, in to_unicode
return obj.decode(charset, errors)
File "/usr/lib64/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 39: ordinal not in range(128)
I'm now considering installing Python3 (Check my other post : Shell.py,
unqualified exec is not allowed), or would it be safer to stay with
Python2.7.5 and just install an older version of web2py ?
Can you help explain this error to me ?
Alexandre
|