Sorry, my bad. Here is the traceback:
2016-07-12 16:12:22,366: ERROR pgadmin: Exception on
/browser/server-group/obj/ [POST]
Traceback (most recent call last):
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1817, in wsgi_app
response = self.full_dispatch_request()
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1475, in full_dispatch_request
rv = self.dispatch_request()
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1461, in dispatch_request
return
self.view_functions[rule.endpoint](**req.view_args)
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask/views.py",
line 84, in view
return self.dispatch_request(*args, **kwargs)
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/browser/utils.py",
line 235, in dispatch_request
return method(*args, **kwargs)
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/browser/server_groups/__init__.py",
line 204, in create
data = request.form if request.form else
json.loads(request.data.decode())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in
position 14: ordinal not in range(128)
How to reproduce:
- Start PgAdmin4;
- Access localhost:5050
- Login
- In the left panel, right click in Servers. Then, "Create >
Server Group", or "Create > Server" (both share the same
error)
- In the "Name field", write any non ASCII word. In my case I
was using the following name: Produção
- Click "Save"
More info about my env:
$ env | grep LANG
LANG=pt_BR.UTF-8
GDM_LANG=pt_BR.UTF-8
$ python --version
Python 2.7.11
$ pip freeze
Babel==1.3
beautifulsoup4==4.4.1
blinker==1.3
django-htmlmin==0.8.0
extras==0.0.3
fixtures==2.0.0
Flask==0.10.1
Flask-Babel==0.9
Flask-Gravatar==0.4.2
Flask-Login==0.2.11
Flask-Mail==0.9.1
Flask-Principal==0.4.0
Flask-Security==1.7.4
Flask-SQLAlchemy==2.0
Flask-WTF==0.11
html5lib==1.0b3
importlib==1.0.3
itsdangerous==0.24
Jinja2==2.7.3
linecache2==1.0.0
MarkupSafe==0.23
passlib==1.6.2
pbr==1.9.1
pgadmin4==1.0b2
psycopg2==2.5.2
pycrypto==2.6.1
pyrsistent==0.11.13
python-dateutil==2.5.0
python-mimeparse==1.5.1
pytz==2014.10
simplejson==3.6.5
six==1.9.0
speaklater==1.3
SQLAlchemy==0.9.8
sqlparse==0.1.19
testscenarios==0.5.0
testtools==2.0.0
traceback2==1.4.0
unittest2==1.1.0
Werkzeug==0.9.6
WTForms==2.0.2
I'm not familiar with the code base yet, but not necessarily all
occurrences of "decode()" need to be patched, just the ones that
deal with user input.
I've done some further testing and noticed that even running an
insert or update with non ASCII text runs into failure. This "update
users set cidade='Brasília' where id=1;", results in the
following traceback:
2016-07-12 16:32:59,964: ERROR pgadmin: Exception on
/sqleditor/query_tool/start/2760583 [POST]
Traceback (most recent call last):
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1817, in wsgi_app
response = self.full_dispatch_request()
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1475, in full_dispatch_request
rv = self.dispatch_request()
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask/app.py",
line 1461, in dispatch_request
return
self.view_functions[rule.endpoint](**req.view_args)
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/flask_login.py",
line 758, in decorated_view
return func(*args, **kwargs)
File
"/home/magnun/venv/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/tools/sqleditor/__init__.py",
line 241, in start_query_tool
sql = json.loads(request.data.decode())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in
position 48: ordinal not in range(128)
But, the other way around isn't true. Executing the update mentioned
above in psql and then running a select in PgAdmin4 (select *
from users where id=1) works fine.
I'll give it a try with Python 3 as soon as possible, it might solve
all the issues since it uses unicode by default.
Thanks in advance.
---
Magnun Leno