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

Avoiding the error - ValueError: invalid literal for int() with base 10 #201

Merged
merged 1 commit into from
Jun 29, 2021

Conversation

Anderseta
Copy link
Contributor

Traceback (most recent call last):
File "/opt/mailbox/inbox.py", line 161, in read_imap
for uid, message in unread_inbox_messages:
File "/usr/local/lib/python3.6/site-packages/imbox-0.9.8-py3.6.egg/imbox/messages.py", line 55, in _fetch_email_list
yield uid, self._fetch_email(uid)
File "/usr/local/lib/python3.6/site-packages/imbox-0.9.8-py3.6.egg/imbox/messages.py", line 44, in _fetch_email
parser_policy=self.parser_policy)
File "/usr/local/lib/python3.6/site-packages/imbox-0.9.8-py3.6.egg/imbox/parser.py", line 155, in fetch_email_by_uid
email_object = parse_email(raw_email, policy=parser_policy)
File "/usr/local/lib/python3.6/site-packages/imbox-0.9.8-py3.6.egg/imbox/parser.py", line 212, in parse_email
attachment = parse_attachment(part)
File "/usr/local/lib/python3.6/site-packages/imbox-0.9.8-py3.6.egg/imbox/parser.py", line 122, in parse_attachment
filename_parts.insert(int(s_name[1]),value[1:-1] if value.startswith('"') else value)
ValueError: invalid literal for int() with base 10: ''

I think the problem is because (not sure):
For some pdf attachments the filename field is empty. This is because sometimes the file name is indicated in the content-type field.

This simple change avoid the whole script loop being stuck

I think the problem is because:
For some pdf attachments the filename field is empty. This is because sometimes the file name is indicated in the content-type field.

This change avoid the whole script loop being stuck
@martinrusev martinrusev merged commit c15838f into martinrusev:master Jun 29, 2021
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

Successfully merging this pull request may close these issues.

2 participants