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

AttributeError: 'int' object has no attribute 'decode' #242

Open
dismine opened this issue Nov 24, 2020 · 3 comments
Open

AttributeError: 'int' object has no attribute 'decode' #242

dismine opened this issue Nov 24, 2020 · 3 comments
Labels

Comments

@dismine
Copy link

dismine commented Nov 24, 2020

Hi.

django-mailbox==4.8.1

From time to time when I call getmail command I get:

File "/opt/env/lib/python3.7/site-packages/django_mailbox/management/commands/getmail.py", line 25, in handle
    for message in messages:
  File "/opt/env/lib/python3.7/site-packages/django_mailbox/models.py", line 413, in get_new_mail
    for message in connection.get_message(condition):
  File "/opt/env/lib/python3.7/site-packages/django_mailbox/transports/imap.py", line 118, in get_message
    message = self.get_email_from_bytes(msg_contents[0][1])
  File "/opt/env/lib/python3.7/site-packages/django_mailbox/transports/base.py", line 15, in get_email_from_bytes
    message = email.message_from_bytes(contents)
  File "/usr/lib/python3.7/email/__init__.py", line 46, in message_from_bytes
    return BytesParser(*args, **kws).parsebytes(s)
  File "/usr/lib/python3.7/email/parser.py", line 123, in parsebytes
    text = text.decode('ASCII', errors='surrogateescape')
AttributeError: 'int' object has no attribute 'decode'
@pfouque pfouque added the bug label Dec 23, 2023
@lampslave
Copy link

This may occur when server returns error, something like [b'System Error (Failure)'] and [b'System Error (Failure)'][0][1] is 121 because these are bytes, not str.

@smjaberl
Copy link

smjaberl commented Aug 2, 2024

I think it is a issue with the imaplib. My setup is a python 3.12.4 and imaplib in version 2.58.
There is often the exception AttributeError: 'int' object has no attribute 'decode'
I refactor my code and used imap_tools in version 1.7.1 and all things are fine.

Why do I answer here? I didn't found a better place after searching the issue.

@pfouque
Copy link
Collaborator

pfouque commented Aug 8, 2024

Thanks @smjaberl for this precious feedback!
it would be interesting to see how difficult it would be to implement this library...
Could you share some samples?

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

4 participants