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 #7

Open
mapopescu opened this issue Jan 30, 2012 · 8 comments
Open

UnicodeDecodeError #7

mapopescu opened this issue Jan 30, 2012 · 8 comments

Comments

@mapopescu
Copy link

Hi,

Thanks for the great work so far!

I had this error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 152: ordinal not in range(128)

I am using an account with 2-steps authentication (sign in OK).
My system is Windows 7 32 bit English, Python 2.7.

I modified one file
messageinfo.py
__newestMessageSec = time.mktime([1970, 1, 1, 0, 0, 0, 0, 0, 0])
->
__newestMessageSec = time.mktime([1980, 1, 1, 0, 0, 0, 0, 0, 0])

Here is the full error message:
..
[2012-01-30 16:37:21,589] Logging out
[2012-01-30 16:37:22,026] Identifying "me" messages
Traceback (most recent call last):
File "main.py", line 251, in
message_infos = GetMessageInfos(opts)
File "main.py", line 102, in GetMessageInfos
for name, address in message_info.GetRecipients():
File "D:\Marius\npinto-mail-trends\messageinfo.py", line 81, in GetRecipients
tos + ccs + resent_tos + resent_ccs)
File "d:\python27\lib\email\utils.py", line 106, in getaddresses
all = COMMASPACE.join(fieldvalues)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 152: ordinal not in range(128)

Thanks again,
Marius

@npinto
Copy link
Owner

npinto commented Jan 30, 2012

Marius,

What is the output of locale on your machine ?

N

@mapopescu
Copy link
Author

Nicolas,

(None, None) 

> > > locale.getdefaultlocale()
> > > ('fr_FR', 'cp1252')
> > > locale.localeconv()
> > > {'mon_decimal_point': '', 'int_frac_digits': 127, 'p_sep_by_space': 127, 'frac_d
> > > igits': 127, 'thousands_sep': '', 'n_sign_posn': 127, 'decimal_point': '.', 'int
> > > _curr_symbol': '', 'n_cs_precedes': 127, 'p_sign_posn': 127, 'mon_thousands_sep'
> > > : '', 'negative_sign': '', 'currency_symbol': '', 'n_sep_by_space': 127, 'mon_gr
> > > ouping': [], 'p_cs_precedes': 127, 'positive_sign': '', 'grouping': []}```

Is this what you need?

Marius

@npinto
Copy link
Owner

npinto commented Jan 31, 2012

This looks like a locale problem. Please update to include Unicode (UTF-8), e.g. fr_FR.UTF-8

@mapopescu
Copy link
Author

Hi,

I guess you mean calling setlocale.
It doesn't work with fr_FR.UTF-8, nor with
>>> locale.setlocale(locale.LC_CTYPE, 'fr_FR.ISO8859-1') locale.Error: unsupported locale setting

I tried, this is the one that works:

'French_France.1252'

> > > locale.getlocale()
> > > ('fr_FR', 'cp1252')```

Thanks for your help, I'll try again the whole script using this locale.

Marius

@mapopescu
Copy link
Author

I just tried again, same error.
Probably I need to find out how to choose a Unicode locale in Windows.
I tried all aliases I found in my locale.py file, all Unicode french ones don't work, unsupported locale.

Another track I'm looking at is to add decoding of the headers before calling email.utils.getaddresses in message_info.GetRecipients():
all_recipients = email.utils.getaddresses( tos + ccs + resent_tos + resent_ccs)
maybe using pyzmail.

I'll take a look after my holiday, in about 2 weeks.

Marius

@npinto
Copy link
Owner

npinto commented Feb 16, 2012

Ok let me know how it goes, it's hard for me to debug this since I don't use Windows.

@ngulden
Copy link

ngulden commented Mar 30, 2013

Hi,

I have the same error:
[2013-03-30 19:35:37,560] Logging out
[2013-03-30 19:35:37,854] Identifying "me" messages
Traceback (most recent call last):
File "main.py", line 251, in
message_infos = GetMessageInfos(opts)
File "main.py", line 102, in GetMessageInfos
for name, address in message_info.GetRecipients():
File "/home/nico/dev/src/mail-trends/messageinfo.py", line 81, in GetRecipients
tos + ccs + resent_tos + resent_ccs)
File "/usr/lib/python2.7/email/utils.py", line 106, in getaddresses
all = COMMASPACE.join(fieldvalues)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 152: ordinal not in range(128)

My system: Debian Testing. Python 2.7.3.
echo $LANG → de_DE.UTF-8

import locale
locale.getdefaultlocale()
('de_DE', 'UTF-8')

@ngulden
Copy link

ngulden commented Mar 30, 2013

Update: I just saw, I checked out the original repository. Trying your checkout, the problem does not occur as reported. Everything seems fine for me. Thanks.

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

No branches or pull requests

3 participants