has_membership('unicode string') raise an UnicodeDecodeError exception

37 views
Skip to first unread message

Dmitry Mosin

unread,
May 23, 2019, 2:55:57 AM5/23/19
to web2py-users
Hello!

After upgrading the framework from 2.9.5 to 2.18.5 a code like this
auth.has_membership(role='Супервизор') or auth.has_membership(auth.id_group('Супервизор'))
leads to UnicodeDecodeError exception.

Even db.auth_group.role == 'Супервизор' in /app/appadmin/select/db throws an exception
(but with db.apt_auth_group.id>0 all records are visible)

    Traceback (most recent call last):
  File "/var/www/web2py/applications/app/controllers/appadmin.py", line 245, in select
    nrows = db(query, ignore_common_filters=True).count()
  File "/var/www/web2py/gluon/packages/dal/pydal/objects.py", line 2385, in count
    return db._adapter.count(self.query, distinct)
  File "/var/www/web2py/gluon/packages/dal/pydal/adapters/base.py", line 791, in count
    self.execute(self._count(query, distinct))
  File "/var/www/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 67, in wrap
    return f(*args, **kwargs)
  File "/var/www/web2py/gluon/packages/dal/pydal/adapters/base.py", line 413, in execute
    rv = self.cursor.execute(command, *args[1:], **kwargs)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 72: ordinal not in range(128)

Any suggestions?

黄祥

unread,
May 23, 2019, 3:56:08 AM5/23/19
to web2py-users
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 72: ordinal not in range(128)

Any suggestions?

perhaps you need to set LANG environment system variables 
e.g. not tested
export LC_ALL=C.UTF-8
export LANG=C.UTF-8

seen many case error during run python 3 apps like this, especially in docker linux container, n cured by set LANG variables

best regards,
stifan

Dmitry Mosin

unread,
May 23, 2019, 4:19:39 AM5/23/19
to web2py-users
perhaps you need to set LANG environment system variables 
export LC_ALL=C.UTF-8

I'll try, but old version still works with LANG=C


seen many case error during run python 3 apps like this, especially in docker linux container, n cured by set LANG variables
There is Python2.7...
 

Dmitry Mosin

unread,
May 23, 2019, 9:49:27 AM5/23/19
to web...@googlegroups.com
Solution is simple (maybe not so obvious), the problem caused by newer FreeTDS version

So I've changed:
db = DAL('mssql://DSN=APP_DSN;UID=dbuser;PWD=dbpass', db_codec='utf-8', ....
to
db = DAL('mssql2://DSN=APP_DSN;UID=dbuser;PWD=dbpass', db_codec='utf-8', ....

And everything is OK now.
Reply all
Reply to author
Forward
0 new messages