Re: TypeError: Unicode-objects and buffer interface
Hello Armin, wow, that was quick help! Thanks a lot! My app now works as I want it to :-) Greetings, Heiko Am Dienstag, 10. November 2015 12:58:26 UTC+1 schrieb Armin Ronacher: > > Hi, > > This was a regression in the newly released Werkzeug 0.11 for Python 3 > users. I just pushed out a new version 0.11.1 that fixes this. Note that > host needs to be a string and not bytes on Python 3 so you should remove > the `b` prefix. > > Regards, > Armin > > On 10/11/2015 12:39, Heiko O wrote: > > Hi all, > > I read the warning that Python 3 support is higly experimental and that > feedback is welcome. > So here's a thing i came accross :-) > > I'm writing a Flask application which used to work fine with python 3.4 > and these packages: > > alembic==0.8.2itsdangerous==0.24 > blinker==1.4 Jinja2==2.8 > click==5.1Mako==1.0.2 > configobj==5.0.6 Markdown==2.6.2 > decorator==4.0.2 MarkupSafe==0.23 > dominate==2.1.12 mod-wsgi==4.4.13 > Flask==0.10.1 passlib==1.6.5 > Flask-Admin==1.3.0pbr==1.8.0 > flask-appconfig==0.11.0 psycopg2==2.6.1 > Flask-Bootstrap==3.3.5.6 py-bcrypt==0.4 > Flask-Login==0.2.11 python-editor==0.4 > Flask-Mail==0.9.1 six==1.9.0 > Flask-Migrate==1.6.0 sqlacodegen==1.1.6 > Flask-Principal==0.4.0SQLAlchemy==1.0.8 > Flask-Script==2.0.5 sqlalchemy-migrate==0.10.0 > Flask-Security==1.7.4 sqlparse==0.1.16 > Flask-SQLAlchemy==2.0 Tempita==0.5.2 > Flask-WTF==0.12 virtualenv==1.11.6 > inflect==0.2.5Werkzeug==0.10.4 > wheel==0.24.0 > WTForms==2.0.2 > > I use a little start-script for developing which looks like this: > > #!/usr/bin/env python3 > # -*- coding: utf-8 -*- > > from myapp import app > app.debug = True > > print(__name__) > > if __name__ == '__main__': > app.run(host='0.0.0.0',debug=True) > > > Everything works fine. > Now i wanted to use more up-to-date packages (but Python is still version > 3.4): > > alembic==0.8.3 itsdangerous==0.24 > blinker==1.4Jinja2==2.8 > click==5.1 Mako==1.0.3 > configobj==5.0.6Markdown==2.6.4 > decorator==4.0.4MarkupSafe==0.23 > dominate==2.1.16mod-wsgi==4.4.21 > Flask==0.10.1 passlib==1.6.5 > Flask-Admin==1.3.0 pbr==1.8.1 > flask-appconfig==0.11.1 psycopg2==2.6.1 > Flask-Bootstrap==3.3.5.7py-bcrypt==0.4 > Flask-Login==0.3.2 python-editor==0.4 > Flask-Mail==0.9.1 six==1.10.0 > Flask-Migrate==1.6.0sqlacodegen==1.1.6 > Flask-Principal==0.4.0 SQLAlchemy==1.0.9 > Flask-Script==2.0.5 sqlalchemy-migrate==0.10.0 > Flask-Security==1.7.4 sqlparse==0.1.18 > Flask-SQLAlchemy==2.1 Tempita==0.5.2 > Flask-WTF==0.12 virtualenv==13.1.2 > inflect==0.2.5 visitor==0.1.2 > Werkzeug==0.11 > wheel==0.24.0 > WTForms==2.0.2 > > When i run my start-script i get: > > /home/user/testenv2/lib/python3.4/site-packages/flask_sqlalchemy/__init__.py:800: > > UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds > significant overhead and will be disabled by default in the future. Set > it to True to suppress this warning. > warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead > and will be disabled by default in the future. Set it to True to suppress > this warning.') > __main__ > * Restarting with stat > /home/user/testenv2/lib/python3.4/site-packages/flask_sqlalchemy/__init__.py:800: > > UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead > and will be disabled by default in the future. Set it to True to > suppress this warning. > warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead > and will be disabled by default in the future. Set it to True to suppress > this warning.') > __main__ > * Debugger is active! > Traceback (most recent call last): > File "./run.py", line 11, in > app.run(host='0.0.0.0',debug=True) > File "/home/user/testenv2/lib/python3.4/site-packages/flask/app.py", > line 772, in run > run_simple(host, port, self, **options) > File > "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/serving.py", line > 633, in run_simple > application = DebuggedApplication(application, use_evalex) > File > "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/debug/__init__.py", > line 169, in __init__ > if self.pin is None: > File > "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/debug/__init__.py", > line 179, in _get_pin > self._pin, self._pin_cookie = get_pin_and_cookie_name(self.app) > File > "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/debug/__init__.py", > line 96, in get_pin_and_cookie_name > h.update('cookiesalt') > TypeError: Unicode-objects must be encoded before hashing > > > So I changed the start-script to: > >
TypeError: Unicode-objects and buffer interface
Hi all, I read the warning that Python 3 support is higly experimental and that feedback is welcome. So here's a thing i came accross :-) I'm writing a Flask application which used to work fine with python 3.4 and these packages: alembic==0.8.2itsdangerous==0.24 blinker==1.4 Jinja2==2.8 click==5.1Mako==1.0.2 configobj==5.0.6 Markdown==2.6.2 decorator==4.0.2 MarkupSafe==0.23 dominate==2.1.12 mod-wsgi==4.4.13 Flask==0.10.1 passlib==1.6.5 Flask-Admin==1.3.0pbr==1.8.0 flask-appconfig==0.11.0 psycopg2==2.6.1 Flask-Bootstrap==3.3.5.6 py-bcrypt==0.4 Flask-Login==0.2.11 python-editor==0.4 Flask-Mail==0.9.1 six==1.9.0 Flask-Migrate==1.6.0 sqlacodegen==1.1.6 Flask-Principal==0.4.0SQLAlchemy==1.0.8 Flask-Script==2.0.5 sqlalchemy-migrate==0.10.0 Flask-Security==1.7.4 sqlparse==0.1.16 Flask-SQLAlchemy==2.0 Tempita==0.5.2 Flask-WTF==0.12 virtualenv==1.11.6 inflect==0.2.5Werkzeug==0.10.4 wheel==0.24.0 WTForms==2.0.2 I use a little start-script for developing which looks like this: #!/usr/bin/env python3 # -*- coding: utf-8 -*- from myapp import app app.debug = True print(__name__) if __name__ == '__main__': app.run(host='0.0.0.0',debug=True) Everything works fine. Now i wanted to use more up-to-date packages (but Python is still version 3.4): alembic==0.8.3 itsdangerous==0.24 blinker==1.4Jinja2==2.8 click==5.1 Mako==1.0.3 configobj==5.0.6Markdown==2.6.4 decorator==4.0.4MarkupSafe==0.23 dominate==2.1.16mod-wsgi==4.4.21 Flask==0.10.1 passlib==1.6.5 Flask-Admin==1.3.0 pbr==1.8.1 flask-appconfig==0.11.1 psycopg2==2.6.1 Flask-Bootstrap==3.3.5.7py-bcrypt==0.4 Flask-Login==0.3.2 python-editor==0.4 Flask-Mail==0.9.1 six==1.10.0 Flask-Migrate==1.6.0sqlacodegen==1.1.6 Flask-Principal==0.4.0 SQLAlchemy==1.0.9 Flask-Script==2.0.5 sqlalchemy-migrate==0.10.0 Flask-Security==1.7.4 sqlparse==0.1.18 Flask-SQLAlchemy==2.1 Tempita==0.5.2 Flask-WTF==0.12 virtualenv==13.1.2 inflect==0.2.5 visitor==0.1.2 Werkzeug==0.11 wheel==0.24.0 WTForms==2.0.2 When i run my start-script i get: /home/user/testenv2/lib/python3.4/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning. warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.') __main__ * Restarting with stat /home/user/testenv2/lib/python3.4/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning. warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.') __main__ * Debugger is active! Traceback (most recent call last): File "./run.py", line 11, in app.run(host='0.0.0.0',debug=True) File "/home/user/testenv2/lib/python3.4/site-packages/flask/app.py", line 772, in run run_simple(host, port, self, **options) File "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/serving.py", line 633, in run_simple application = DebuggedApplication(application, use_evalex) File "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/debug/__init__.py", line 169, in __init__ if self.pin is None: File "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/debug/__init__.py", line 179, in _get_pin self._pin, self._pin_cookie = get_pin_and_cookie_name(self.app) File "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/debug/__init__.py", line 96, in get_pin_and_cookie_name h.update('cookiesalt') TypeError: Unicode-objects must be encoded before hashing So I changed the start-script to: if __name__ == '__main__': app.run(host="0.0.0.0".encode('utf8'),debug=True) Now I get this: /home/user/testenv2/lib/python3.4/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning. warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.') __main__ Traceback (most recent call last): File "./run.py", line 11, in app.run(host="0.0.0.0".encode('utf8'),debug=True) File "/home/user/testenv2/lib/python3.4/site-packages/flask/app.py", line 772,
Re: TypeError: Unicode-objects and buffer interface
Hi, This was a regression in the newly released Werkzeug 0.11 for Python 3 users. I just pushed out a new version 0.11.1 that fixes this. Note that host needs to be a string and not bytes on Python 3 so you should remove the `b` prefix. Regards, Armin On 10/11/2015 12:39, Heiko O wrote: Hi all, I read the warning that Python 3 support is higly experimental and that feedback is welcome. So here's a thing i came accross :-) I'm writing a Flask application which used to work fine with python 3.4 and these packages: alembic==0.8.2itsdangerous==0.24 blinker==1.4 Jinja2==2.8 click==5.1Mako==1.0.2 configobj==5.0.6 Markdown==2.6.2 decorator==4.0.2 MarkupSafe==0.23 dominate==2.1.12 mod-wsgi==4.4.13 Flask==0.10.1 passlib==1.6.5 Flask-Admin==1.3.0pbr==1.8.0 flask-appconfig==0.11.0 psycopg2==2.6.1 Flask-Bootstrap==3.3.5.6 py-bcrypt==0.4 Flask-Login==0.2.11 python-editor==0.4 Flask-Mail==0.9.1 six==1.9.0 Flask-Migrate==1.6.0 sqlacodegen==1.1.6 Flask-Principal==0.4.0SQLAlchemy==1.0.8 Flask-Script==2.0.5 sqlalchemy-migrate==0.10.0 Flask-Security==1.7.4 sqlparse==0.1.16 Flask-SQLAlchemy==2.0 Tempita==0.5.2 Flask-WTF==0.12 virtualenv==1.11.6 inflect==0.2.5Werkzeug==0.10.4 wheel==0.24.0 WTForms==2.0.2 I use a little start-script for developing which looks like this: #!/usr/bin/env python3 # -*- coding: utf-8 -*- from myapp import app app.debug = True print(__name__) if __name__ == '__main__': app.run(host='0.0.0.0',debug=True) Everything works fine. Now i wanted to use more up-to-date packages (but Python is still version 3.4): alembic==0.8.3 itsdangerous==0.24 blinker==1.4Jinja2==2.8 click==5.1 Mako==1.0.3 configobj==5.0.6Markdown==2.6.4 decorator==4.0.4MarkupSafe==0.23 dominate==2.1.16mod-wsgi==4.4.21 Flask==0.10.1 passlib==1.6.5 Flask-Admin==1.3.0 pbr==1.8.1 flask-appconfig==0.11.1 psycopg2==2.6.1 Flask-Bootstrap==3.3.5.7py-bcrypt==0.4 Flask-Login==0.3.2 python-editor==0.4 Flask-Mail==0.9.1 six==1.10.0 Flask-Migrate==1.6.0sqlacodegen==1.1.6 Flask-Principal==0.4.0 SQLAlchemy==1.0.9 Flask-Script==2.0.5 sqlalchemy-migrate==0.10.0 Flask-Security==1.7.4 sqlparse==0.1.18 Flask-SQLAlchemy==2.1 Tempita==0.5.2 Flask-WTF==0.12 virtualenv==13.1.2 inflect==0.2.5 visitor==0.1.2 Werkzeug==0.11 wheel==0.24.0 WTForms==2.0.2 When i run my start-script i get: /home/user/testenv2/lib/python3.4/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning. warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.') __main__ * Restarting with stat /home/user/testenv2/lib/python3.4/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning. warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.') __main__ * Debugger is active! Traceback (most recent call last): File "./run.py", line 11, in app.run(host='0.0.0.0',debug=True) File "/home/user/testenv2/lib/python3.4/site-packages/flask/app.py", line 772, in run run_simple(host, port, self, **options) File "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/serving.py", line 633, in run_simple application = DebuggedApplication(application, use_evalex) File "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/debug/__init__.py", line 169, in __init__ if self.pin is None: File "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/debug/__init__.py", line 179, in _get_pin self._pin, self._pin_cookie = get_pin_and_cookie_name(self.app) File "/home/user/testenv2/lib/python3.4/site-packages/werkzeug/debug/__init__.py", line 96, in get_pin_and_cookie_name h.update('cookiesalt') TypeError: Unicode-objects must be encoded before hashing So I changed the start-script to: if __name__ == '__main__': app.run(host="0.0.0.0".encode('utf8'),debug=True) Now I get this: /home/user/testenv2/lib/python3.4/site-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning. warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead