You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UnboundLocalError in email.message.Message.get_payload #134759
changed the title [-]UnboundLocalError: local variable 'bpayload' referenced before assignment[/-][+]`UnboundLocalError` in `email.message.Message.get_payload`[/+]on May 26, 2025
As mentioned by @picnixz, the error must be on line 317. To get here I use email message with quoted-printable encoding and body message surely get into quopri.decodestring but (luckly?) it does not fall. Am I miss something?
OS: Linux (Ubuntu 24.04.2 LTS)
Python: Python 3.15.0a0
We can't just use a list because if is_multipart() would return true and we would early exit. So we need to use a bytes payload with decode = True (I think).
Activity
[-]UnboundLocalError: local variable 'bpayload' referenced before assignment[/-][+]`UnboundLocalError` in `email.message.Message.get_payload`[/+]picnixz commentedon May 26, 2025
The error is here:
cpython/Lib/email/message.py
Lines 316 to 317 in 96905bd
cc @bitdancer
makridenko commentedon May 27, 2025
hi, can i work on this?
skv0zsneg commentedon May 27, 2025
Hello! I would like to work on it but did not work with CPython at all. Will it be a problem? If not where I should start with?
sobolevn commentedon May 27, 2025
Hi, @skv0zsneg and @makridenko! Thanks a lot for your interest.
@makridenko since you were first, you can surely work on this. Because it looks like that no one else has started yet.
@skv0zsneg we value new contributors, please, don't feel left out :) You can pick any other issue from the opened ones 🤝
skv0zsneg commentedon Jun 27, 2025
Hey everyone!
Trying to reproduce this bug
UnboundLocalErrorbut it want falling.What I'm doing in REPL:
As mentioned by @picnixz, the error must be on line 317. To get here I use email message with
quoted-printableencoding and body message surely get intoquopri.decodestringbut (luckly?) it does not fall. Am I miss something?OS: Linux (Ubuntu 24.04.2 LTS)
Python: Python 3.15.0a0
picnixz commentedon Jun 27, 2025
The "bad" code path is only taken when
payloadis not a string,cte == 'quoted-printable'anddecodeis True. Considering there isWe can't just use a list because if
is_multipart()would return true and we would early exit. So we need to use a bytes payload withdecode = True(I think).gh-134759: fix `UnboundLocalError` in `email.message.Message.get_payl…
pythongh-134759: fix `UnboundLocalError` in `email.message.Message.ge…
pythongh-134759: fix `UnboundLocalError` in `email.message.Message.ge…
[3.13] gh-134759: fix `UnboundLocalError` in `email.message.Message.g…
[3.14] gh-134759: fix `UnboundLocalError` in `email.message.Message.g…
pythongh-134759: fix `UnboundLocalError` in `email.message.Message.ge…
pythongh-134759: fix `UnboundLocalError` in `email.message.Message.ge…
pythongh-134759: fix `UnboundLocalError` in `email.message.Message.ge…
pythongh-134759: fix `UnboundLocalError` in `email.message.Message.ge…
[3.14] pythongh-134759: fix `UnboundLocalError` in `email.message.Mes…