Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request improves cross-platform compatibility between Python 2 and 3 by refactoring email attachment handling logic and updating corresponding tests. The changes focus on standardizing MIME type handling, base64 encoding, and payload decoding to ensure consistent behavior across Python versions.
Key changes:
- Standardized attachment encoding/decoding to use base64 encoding consistently
- Simplified MIME type detection and attachment creation logic
- Updated tests to handle decoded attachment content properly
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| qreu/email.py | Refactored add_attachment method to use consistent base64 encoding and improved attachments property to decode payloads automatically |
| spec/qreu_spec.py | Updated test cases to decode attachment content and removed legacy Python 2 compatibility code |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
polsala
approved these changes
Jul 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the email attachment handling in
qreu/email.pyto improve MIME type handling, base64 encoding, and payload decoding. It also updates the corresponding tests inspec/qreu_spec.pyto align with the changes. The most important changes include restructuring theadd_attachmentmethod, fixing payload decoding in theattachmentsmethod, and cleaning up the test cases.Refactoring in
qreu/email.py:Improved MIME type handling and base64 encoding in
add_attachment:base64.b64encodefor encoding andmimetypes.guess_typefor determining the MIME type.Fixed payload decoding in
attachments:get_payloadto decode the content automatically by passingdecode=True.Updates in
spec/qreu_spec.py:Test updates for attachment content decoding:
.decode('utf-8')for comparison with expected values. [1] [2]Removed outdated and commented code: