Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte #10

Open
fb-erik opened this issue Nov 7, 2016 · 6 comments
Labels

Comments

@fb-erik
Copy link

fb-erik commented Nov 7, 2016

I am using the email backend on django 1.8.16 and have tried both python 3.4.2 and 3.5.2 but always get the following error in the spooler:

django_uwsgi/decorators.py", line 38, in _decode1
    return val.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

so I thought maybe it is the decode call on line 38 in the decorators and tried adding "ignore", but then I get the following error:

django_uwsgi/task.py", line 15, in send_mail
    conn.send_messages([pickle.loads(arguments['body'])])
TypeError: a bytes-like object is required, not 'str'

which feels like maybe there is some python 3 incompatibility?
I'm also using the email backend on a site that uses python 2.7 where everything works fine.

@MechanisM MechanisM added the bug label Nov 7, 2016
@MechanisM
Copy link
Collaborator

MechanisM commented Nov 7, 2016

Thanks for report. I'll look into it a bit later.
Yeah, uwsgi spooler needs bytes, not strings if running on python3
Recently I wanted to ditch python2.7 support, from this package.
I'll fix this after next release(which is coming soon).
Btw, decorators.py taken from uwsgi repo https://github.com/unbit/uwsgi/blob/master/uwsgidecorators.py and mostly not touched, except some imports. I'm using this file "as is", and if this file should be modified, it should be done in uwsgi repo. I'll try to figure it out.

@fb-erik
Copy link
Author

fb-erik commented Nov 8, 2016

Thanks @MechanisM I appreciate it.

@ypokkinen
Copy link

I am just installed django version 1.11.5 and python 3.6.2. Got the same error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 3: invalid start byte. When I started django miniserver.

@tyrantqiao
Copy link

same error as @ypokkinen
Not sure why I type string in '.py', run cmd 'python3 xx.py runserver', choose the app site and get UnicodeError

@toabi
Copy link

toabi commented Aug 21, 2019

We are having the same issue with python3.4

@toabi
Copy link

toabi commented Aug 21, 2019

Ineed the issue is here: https://github.com/unbit/uwsgi/blob/2.0.18/uwsgidecorators.py#L29-L33 - it tries to decode the bytes although they were never unicode-encoded because pickle.dumps created the bytes.

A try … catch UnicodeDecodeError: return val in the decorators.py is a quickfix for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants