mirror of
https://github.com/HaschekSolutions/opentrashmail.git
synced 2026-04-25 14:45:59 +03:00
[GH-ISSUE #101] LAST_CLEANUP causes UnboundLocalError due to missing global declaration in cleanup() #74
Labels
No labels
bug
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentrashmail#74
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Aejs on GitHub (Jul 4, 2025).
Original GitHub issue: https://github.com/HaschekSolutions/opentrashmail/issues/101
Description
The
cleanup()function uses the global variableLAST_CLEANUPbut does not declare it asglobal.This leads to an
UnboundLocalErrorwhen the function is called, because Python treats any assignment to a variable as a local variable unless it's explicitly declared as global.Error message
This happens at the line:
Later in the same function, the value is reassigned:
This causes Python to treat
LAST_CLEANUPas a local variable, but it's accessed before being set.Suggested fix
Add a
global LAST_CLEANUPdeclaration at the beginning of thecleanup()function:Real-world impact
This bug causes inbound emails to be rejected with a 500 error during SMTP processing.
Here is a real example of a bounce message sent back to the sender:
This results in:
Recommendation
A minimal fix is to add the missing
global LAST_CLEANUPstatement.@proodle commented on GitHub (Aug 11, 2025):
This bug is giving me some trouble, too. When I send a test mail via AWS SES to my Open Trashmail account (v1.5.0), Amazon receives a 500 error and automatically puts the mail address on a blacklist.
After applying Aejs's fix, it works fine.
Can you please create a pull request for this fix? I think it is really important.
@Aejs commented on GitHub (Aug 11, 2025):
@proodle just created an pull request.
@Aejs commented on GitHub (Aug 13, 2025):
Pull Request is merged. Close