question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error when parsing attachment

See original GitHub issue

I am running the example provided by README, My python version is 3.5, on windows platform, here is the error message, please take a look.

Traceback (most recent call last):
  File "C:\Users\**\Miniconda3\lib\base64.py", line 518, in _input_type_check
    m = memoryview(s)
TypeError: memoryview: a bytes-like object is required, not 'str'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "D:/Project/account-adapter/imbox_downloader.py", line 61, in <module>
    for uid, message in all_messages:
  File "C:\Users\**\Miniconda3\lib\site-packages\imbox\__init__.py", line 50, in fetch_list
    yield (uid, self.fetch_by_uid(uid))
  File "C:\Users\**\Miniconda3\lib\site-packages\imbox\__init__.py", line 41, in fetch_by_uid
    email_object = parse_email(raw_email)
  File "C:\Users\**\Miniconda3\lib\site-packages\imbox\parser.py", line 160, in parse_email
    attachment = parse_attachment(part)
  File "C:\Users\**\Miniconda3\lib\site-packages\imbox\parser.py", line 102, in parse_attachment
    name, value = decode_param(param)
  File "C:\Users\**\Miniconda3\lib\site-packages\imbox\parser.py", line 74, in decode_param
    value = base64.decodestring(code)
  File "C:\Users\**\Miniconda3\lib\base64.py", line 560, in decodestring
    return decodebytes(s)
  File "C:\Users\**\Miniconda3\lib\base64.py", line 552, in decodebytes
    _input_type_check(s)
  File "C:\Users\**\Miniconda3\lib\base64.py", line 521, in _input_type_check
    raise TypeError(msg) from err
TypeError: expected bytes-like object, not str

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
ghostcommented, Aug 21, 2021

@ChurchillDu please open a new issue. The old one is four years old, not the same issue as yours (the error message is different) and this issue here was already fixed.

0reactions
ChurchillDucommented, Aug 21, 2021

I got this error python3.9 on win10

Traceback (most recent call last):
  File "D:\Code\download_attatchment.py", line 30, in <module>
    for (uid, message) in messages:
  File "D:\Software\Python\lib\site-packages\imbox\messages.py", line 55, in _fetch_email_list
    yield uid, self._fetch_email(uid)
  File "D:\Software\Python\lib\site-packages\imbox\messages.py", line 42, in _fetch_email
    return fetch_email_by_uid(uid=uid,
  File "D:\Software\Python\lib\site-packages\imbox\parser.py", line 155, in fetch_email_by_uid
    email_object = parse_email(raw_email, policy=parser_policy)
  File "D:\Software\Python\lib\site-packages\imbox\parser.py", line 212, in parse_email
    attachment = parse_attachment(part)
  File "D:\Software\Python\lib\site-packages\imbox\parser.py", line 115, in parse_attachment
    name, value = decode_param(param)
  File "D:\Software\Python\lib\site-packages\imbox\parser.py", line 80, in decode_param
    value = base64.decodebytes(code.encode())
  File "D:\Software\Python\lib\base64.py", line 538, in decodebytes
    return binascii.a2b_base64(s)
binascii.Error: Invalid base64-encoded string: number of data characters (109) cannot be 1 more than a multiple of 4
Read more comments on GitHub >

github_iconTop Results From Across the Web

Parse Json error for Attachments - Power Platform Community
Im getting an Error for the parse Json for gathering the values of an attachment. i have posted a screenshot below. the flow...
Read more >
if there is issue with attachment parsing do not discard ...
if there is an issue with attachment parsing do not discard complete email, discard only attachment but process email. as of now, we...
Read more >
Could not parse message attachment. failed to parse field
A detailed guide on how to resolve errors related to "could not parse message attachment. failed to parse field"
Read more >
Error on missing mimetype for attachments when parsing ...
Hi guys, I'm getting a "org.simplejavamail.converter.internal.msgparser.OutlookMessageException: Unable to parse Outlook message" exception ...
Read more >
Getting error while parsing documents - Elastic Discuss
I am using Ingest-attachment for indexing documents. I am able to parse text documents (.txt files). When I try to parse .doc or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found