Update email library v3.13.11#6642
Conversation
📝 WalkthroughWalkthrough
Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/vm/src/stdlib/time.rs (1)
200-206: Hardcoded 3600-second DST offset may be incorrect for some timezones.The calculation
c_timezone - 3600assumes DST offset is always 1 hour, but some regions use different DST offsets (e.g., Lord Howe Island uses 30 minutes). While the FIXME acknowledges this limitation, consider documenting which timezones may return incorrect values or adding a more prominent warning.The implementation follows the existing pattern in this module and is acceptable as a placeholder until proper C
altzonesupport is added.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (93)
Lib/email/_header_value_parser.pyis excluded by!Lib/**Lib/email/_parseaddr.pyis excluded by!Lib/**Lib/email/_policybase.pyis excluded by!Lib/**Lib/email/contentmanager.pyis excluded by!Lib/**Lib/email/feedparser.pyis excluded by!Lib/**Lib/email/generator.pyis excluded by!Lib/**Lib/email/header.pyis excluded by!Lib/**Lib/email/message.pyis excluded by!Lib/**Lib/email/parser.pyis excluded by!Lib/**Lib/email/utils.pyis excluded by!Lib/**Lib/test/support/testresult.pyis excluded by!Lib/**Lib/test/test_email/__init__.pyis excluded by!Lib/**Lib/test/test_email/__main__.pyis excluded by!Lib/**Lib/test/test_email/data/msg_01.txtis excluded by!Lib/**Lib/test/test_email/data/msg_02.txtis excluded by!Lib/**Lib/test/test_email/data/msg_03.txtis excluded by!Lib/**Lib/test/test_email/data/msg_04.txtis excluded by!Lib/**Lib/test/test_email/data/msg_05.txtis excluded by!Lib/**Lib/test/test_email/data/msg_06.txtis excluded by!Lib/**Lib/test/test_email/data/msg_07.txtis excluded by!Lib/**Lib/test/test_email/data/msg_08.txtis excluded by!Lib/**Lib/test/test_email/data/msg_09.txtis excluded by!Lib/**Lib/test/test_email/data/msg_10.txtis excluded by!Lib/**Lib/test/test_email/data/msg_11.txtis excluded by!Lib/**Lib/test/test_email/data/msg_12.txtis excluded by!Lib/**Lib/test/test_email/data/msg_12a.txtis excluded by!Lib/**Lib/test/test_email/data/msg_13.txtis excluded by!Lib/**Lib/test/test_email/data/msg_14.txtis excluded by!Lib/**Lib/test/test_email/data/msg_15.txtis excluded by!Lib/**Lib/test/test_email/data/msg_16.txtis excluded by!Lib/**Lib/test/test_email/data/msg_17.txtis excluded by!Lib/**Lib/test/test_email/data/msg_18.txtis excluded by!Lib/**Lib/test/test_email/data/msg_19.txtis excluded by!Lib/**Lib/test/test_email/data/msg_20.txtis excluded by!Lib/**Lib/test/test_email/data/msg_21.txtis excluded by!Lib/**Lib/test/test_email/data/msg_22.txtis excluded by!Lib/**Lib/test/test_email/data/msg_23.txtis excluded by!Lib/**Lib/test/test_email/data/msg_24.txtis excluded by!Lib/**Lib/test/test_email/data/msg_25.txtis excluded by!Lib/**Lib/test/test_email/data/msg_26.txtis excluded by!Lib/**Lib/test/test_email/data/msg_27.txtis excluded by!Lib/**Lib/test/test_email/data/msg_28.txtis excluded by!Lib/**Lib/test/test_email/data/msg_29.txtis excluded by!Lib/**Lib/test/test_email/data/msg_30.txtis excluded by!Lib/**Lib/test/test_email/data/msg_31.txtis excluded by!Lib/**Lib/test/test_email/data/msg_32.txtis excluded by!Lib/**Lib/test/test_email/data/msg_33.txtis excluded by!Lib/**Lib/test/test_email/data/msg_34.txtis excluded by!Lib/**Lib/test/test_email/data/msg_35.txtis excluded by!Lib/**Lib/test/test_email/data/msg_36.txtis excluded by!Lib/**Lib/test/test_email/data/msg_37.txtis excluded by!Lib/**Lib/test/test_email/data/msg_38.txtis excluded by!Lib/**Lib/test/test_email/data/msg_39.txtis excluded by!Lib/**Lib/test/test_email/data/msg_40.txtis excluded by!Lib/**Lib/test/test_email/data/msg_41.txtis excluded by!Lib/**Lib/test/test_email/data/msg_42.txtis excluded by!Lib/**Lib/test/test_email/data/msg_43.txtis excluded by!Lib/**Lib/test/test_email/data/msg_44.txtis excluded by!Lib/**Lib/test/test_email/data/msg_45.txtis excluded by!Lib/**Lib/test/test_email/data/msg_46.txtis excluded by!Lib/**Lib/test/test_email/data/msg_47.txtis excluded by!Lib/**Lib/test/test_email/data/python.bmpis excluded by!**/*.bmp,!Lib/**Lib/test/test_email/data/python.exris excluded by!Lib/**Lib/test/test_email/data/python.gifis excluded by!**/*.gif,!Lib/**Lib/test/test_email/data/python.jpgis excluded by!**/*.jpg,!Lib/**Lib/test/test_email/data/python.pbmis excluded by!Lib/**Lib/test/test_email/data/python.pgmis excluded by!Lib/**Lib/test/test_email/data/python.pngis excluded by!**/*.png,!Lib/**Lib/test/test_email/data/python.ppmis excluded by!Lib/**Lib/test/test_email/data/python.rasis excluded by!Lib/**Lib/test/test_email/data/python.sgiis excluded by!Lib/**Lib/test/test_email/data/python.tiffis excluded by!**/*.tiff,!Lib/**Lib/test/test_email/data/python.webpis excluded by!Lib/**Lib/test/test_email/data/python.xbmis excluded by!Lib/**Lib/test/test_email/data/sndhdr.aifcis excluded by!Lib/**Lib/test/test_email/data/sndhdr.aiffis excluded by!Lib/**Lib/test/test_email/data/sndhdr.auis excluded by!Lib/**Lib/test/test_email/data/sndhdr.wavis excluded by!**/*.wav,!Lib/**Lib/test/test_email/test__encoded_words.pyis excluded by!Lib/**Lib/test/test_email/test__header_value_parser.pyis excluded by!Lib/**Lib/test/test_email/test_asian_codecs.pyis excluded by!Lib/**Lib/test/test_email/test_contentmanager.pyis excluded by!Lib/**Lib/test/test_email/test_defect_handling.pyis excluded by!Lib/**Lib/test/test_email/test_email.pyis excluded by!Lib/**Lib/test/test_email/test_generator.pyis excluded by!Lib/**Lib/test/test_email/test_headerregistry.pyis excluded by!Lib/**Lib/test/test_email/test_inversion.pyis excluded by!Lib/**Lib/test/test_email/test_message.pyis excluded by!Lib/**Lib/test/test_email/test_parser.pyis excluded by!Lib/**Lib/test/test_email/test_pickleable.pyis excluded by!Lib/**Lib/test/test_email/test_policy.pyis excluded by!Lib/**Lib/test/test_email/test_utils.pyis excluded by!Lib/**Lib/test/test_email/torture_test.pyis excluded by!Lib/**
📒 Files selected for processing (2)
crates/vm/src/bytes_inner.rscrates/vm/src/stdlib/time.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style by runningcargo fmtto format Rust code
Always run clippy to lint code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass,pymodule,pyfunction, etc.) when implementing Python functionality in Rust
Files:
crates/vm/src/stdlib/time.rscrates/vm/src/bytes_inner.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Run tests under miri
- GitHub Check: Run rust tests (windows-latest)
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Check Rust code with clippy
- GitHub Check: Run snippets and cpython tests on wasm-wasi
- GitHub Check: Ensure compilation on various targets
- GitHub Check: Check the WASM package and demo
🔇 Additional comments (1)
crates/vm/src/bytes_inner.rs (1)
1091-1097: LGTM!Adding the
Debugderive toDecodeArgsimproves debuggability. The struct definition is clean and follows the existing patterns in this file.
|
@terryluan12 was there problem in this PR? |
|
I don't remember closing this, whoops. Yes, there are many lol. Please don't merge. I'm planning to keep the PR open while I work on it, if that's alright |
be9a494 to
af6bf40
Compare
|
Code has been automatically formatted The code in this PR has been formatted using:
git pull origin update_email |
4d8deae to
b672bd0
Compare
…r parameter in bytes_decode function in `bytes_inner.rs`
b672bd0 to
e870f9a
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@crates/vm/src/bytes_inner.rs`:
- Around line 1107-1128: The code panics because it calls s.as_str() on a
Surrogate-containing OsString (s) after s.to_str() returned None; update the
branch inside match encoding.as_ref() (the "ignore" | "replace" |
"backslashreplace" arm) to avoid s.as_str() and instead use a lossy conversion
(e.g., s.to_string_lossy()) when producing the fallback encoding string (keep
using crate::codecs::DEFAULT_ENCODING when encoding is None); ensure you still
respect the errors variable and return vm.new_unicode_encode_error where
appropriate.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (94)
Lib/email/_header_value_parser.pyis excluded by!Lib/**Lib/email/_parseaddr.pyis excluded by!Lib/**Lib/email/_policybase.pyis excluded by!Lib/**Lib/email/contentmanager.pyis excluded by!Lib/**Lib/email/feedparser.pyis excluded by!Lib/**Lib/email/generator.pyis excluded by!Lib/**Lib/email/header.pyis excluded by!Lib/**Lib/email/message.pyis excluded by!Lib/**Lib/email/parser.pyis excluded by!Lib/**Lib/email/utils.pyis excluded by!Lib/**Lib/test/test_context.pyis excluded by!Lib/**Lib/test/test_email/__init__.pyis excluded by!Lib/**Lib/test/test_email/__main__.pyis excluded by!Lib/**Lib/test/test_email/data/msg_01.txtis excluded by!Lib/**Lib/test/test_email/data/msg_02.txtis excluded by!Lib/**Lib/test/test_email/data/msg_03.txtis excluded by!Lib/**Lib/test/test_email/data/msg_04.txtis excluded by!Lib/**Lib/test/test_email/data/msg_05.txtis excluded by!Lib/**Lib/test/test_email/data/msg_06.txtis excluded by!Lib/**Lib/test/test_email/data/msg_07.txtis excluded by!Lib/**Lib/test/test_email/data/msg_08.txtis excluded by!Lib/**Lib/test/test_email/data/msg_09.txtis excluded by!Lib/**Lib/test/test_email/data/msg_10.txtis excluded by!Lib/**Lib/test/test_email/data/msg_11.txtis excluded by!Lib/**Lib/test/test_email/data/msg_12.txtis excluded by!Lib/**Lib/test/test_email/data/msg_12a.txtis excluded by!Lib/**Lib/test/test_email/data/msg_13.txtis excluded by!Lib/**Lib/test/test_email/data/msg_14.txtis excluded by!Lib/**Lib/test/test_email/data/msg_15.txtis excluded by!Lib/**Lib/test/test_email/data/msg_16.txtis excluded by!Lib/**Lib/test/test_email/data/msg_17.txtis excluded by!Lib/**Lib/test/test_email/data/msg_18.txtis excluded by!Lib/**Lib/test/test_email/data/msg_19.txtis excluded by!Lib/**Lib/test/test_email/data/msg_20.txtis excluded by!Lib/**Lib/test/test_email/data/msg_21.txtis excluded by!Lib/**Lib/test/test_email/data/msg_22.txtis excluded by!Lib/**Lib/test/test_email/data/msg_23.txtis excluded by!Lib/**Lib/test/test_email/data/msg_24.txtis excluded by!Lib/**Lib/test/test_email/data/msg_25.txtis excluded by!Lib/**Lib/test/test_email/data/msg_26.txtis excluded by!Lib/**Lib/test/test_email/data/msg_27.txtis excluded by!Lib/**Lib/test/test_email/data/msg_28.txtis excluded by!Lib/**Lib/test/test_email/data/msg_29.txtis excluded by!Lib/**Lib/test/test_email/data/msg_30.txtis excluded by!Lib/**Lib/test/test_email/data/msg_31.txtis excluded by!Lib/**Lib/test/test_email/data/msg_32.txtis excluded by!Lib/**Lib/test/test_email/data/msg_33.txtis excluded by!Lib/**Lib/test/test_email/data/msg_34.txtis excluded by!Lib/**Lib/test/test_email/data/msg_35.txtis excluded by!Lib/**Lib/test/test_email/data/msg_36.txtis excluded by!Lib/**Lib/test/test_email/data/msg_37.txtis excluded by!Lib/**Lib/test/test_email/data/msg_38.txtis excluded by!Lib/**Lib/test/test_email/data/msg_39.txtis excluded by!Lib/**Lib/test/test_email/data/msg_40.txtis excluded by!Lib/**Lib/test/test_email/data/msg_41.txtis excluded by!Lib/**Lib/test/test_email/data/msg_42.txtis excluded by!Lib/**Lib/test/test_email/data/msg_43.txtis excluded by!Lib/**Lib/test/test_email/data/msg_44.txtis excluded by!Lib/**Lib/test/test_email/data/msg_45.txtis excluded by!Lib/**Lib/test/test_email/data/msg_46.txtis excluded by!Lib/**Lib/test/test_email/data/msg_47.txtis excluded by!Lib/**Lib/test/test_email/data/python.bmpis excluded by!**/*.bmp,!Lib/**Lib/test/test_email/data/python.exris excluded by!Lib/**Lib/test/test_email/data/python.gifis excluded by!**/*.gif,!Lib/**Lib/test/test_email/data/python.jpgis excluded by!**/*.jpg,!Lib/**Lib/test/test_email/data/python.pbmis excluded by!Lib/**Lib/test/test_email/data/python.pgmis excluded by!Lib/**Lib/test/test_email/data/python.pngis excluded by!**/*.png,!Lib/**Lib/test/test_email/data/python.ppmis excluded by!Lib/**Lib/test/test_email/data/python.rasis excluded by!Lib/**Lib/test/test_email/data/python.sgiis excluded by!Lib/**Lib/test/test_email/data/python.tiffis excluded by!**/*.tiff,!Lib/**Lib/test/test_email/data/python.webpis excluded by!Lib/**Lib/test/test_email/data/python.xbmis excluded by!Lib/**Lib/test/test_email/data/sndhdr.aifcis excluded by!Lib/**Lib/test/test_email/data/sndhdr.aiffis excluded by!Lib/**Lib/test/test_email/data/sndhdr.auis excluded by!Lib/**Lib/test/test_email/data/sndhdr.wavis excluded by!**/*.wav,!Lib/**Lib/test/test_email/test__encoded_words.pyis excluded by!Lib/**Lib/test/test_email/test__header_value_parser.pyis excluded by!Lib/**Lib/test/test_email/test_asian_codecs.pyis excluded by!Lib/**Lib/test/test_email/test_contentmanager.pyis excluded by!Lib/**Lib/test/test_email/test_defect_handling.pyis excluded by!Lib/**Lib/test/test_email/test_email.pyis excluded by!Lib/**Lib/test/test_email/test_generator.pyis excluded by!Lib/**Lib/test/test_email/test_headerregistry.pyis excluded by!Lib/**Lib/test/test_email/test_inversion.pyis excluded by!Lib/**Lib/test/test_email/test_message.pyis excluded by!Lib/**Lib/test/test_email/test_parser.pyis excluded by!Lib/**Lib/test/test_email/test_pickleable.pyis excluded by!Lib/**Lib/test/test_email/test_policy.pyis excluded by!Lib/**Lib/test/test_email/test_utils.pyis excluded by!Lib/**Lib/test/test_email/torture_test.pyis excluded by!Lib/**Lib/test/test_time.pyis excluded by!Lib/**
📒 Files selected for processing (1)
crates/vm/src/bytes_inner.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style usingcargo fmtto format Rust code
Always run clippy to lint code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass,pymodule,pyfunction, etc.) when implementing Python functionality in Rust
Files:
crates/vm/src/bytes_inner.rs
🧠 Learnings (2)
📚 Learning: 2025-08-26T05:20:54.540Z
Learnt from: youknowone
Repo: RustPython/RustPython PR: 6110
File: vm/src/frame.rs:1311-1316
Timestamp: 2025-08-26T05:20:54.540Z
Learning: In RustPython's pattern matching implementation, only certain builtin types should have the SEQUENCE flag: list and tuple are confirmed sequences. The user youknowone indicated that bytes, bytearray are not considered sequences in this context, even though they implement sequence-like protocols.
Applied to files:
crates/vm/src/bytes_inner.rs
📚 Learning: 2025-08-26T05:20:54.540Z
Learnt from: youknowone
Repo: RustPython/RustPython PR: 6110
File: vm/src/frame.rs:1311-1316
Timestamp: 2025-08-26T05:20:54.540Z
Learning: In the RustPython codebase, only certain builtin types should be marked with the SEQUENCE flag for pattern matching. List and tuple are sequences, but bytes, bytearray, and range are not considered sequences in this context, even though they may implement sequence-like protocols.
Applied to files:
crates/vm/src/bytes_inner.rs
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| let encoding: Cow<'_, str> = match encoding.as_ref() { | ||
| Some(s) => match s.to_str() { | ||
| Some(valid_str) => Cow::Borrowed(valid_str), | ||
| None => { | ||
| let Some(errors) = &errors else { | ||
| return Err(vm.new_unicode_encode_error(format!( | ||
| "'{}' codec can't encode characters: surrogates not allowed", | ||
| s | ||
| ))); | ||
| }; | ||
|
|
||
| match errors.as_str() { | ||
| "strict" => { | ||
| return Err( | ||
| vm.new_unicode_encode_error("Struct format must be a UTF-8 string") | ||
| ); | ||
| } | ||
| "ignore" | "replace" | "backslashreplace" => Cow::Borrowed( | ||
| encoding | ||
| .as_ref() | ||
| .map_or(crate::codecs::DEFAULT_ENCODING, |s| s.as_str()), | ||
| ), |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Find PyStr implementations and examine to_str/as_str methods
fd -g 'pystr*.rs' crates --exec rg -l "impl.*PyStr" {} \;Repository: RustPython/RustPython
Length of output: 132
🏁 Script executed:
#!/bin/bash
# More comprehensive search for PyStr type and its methods
rg -n "fn (to_str|as_str|to_string_lossy)" crates/vm/src/ -A 3 | head -100Repository: RustPython/RustPython
Length of output: 2229
🏁 Script executed:
#!/bin/bash
# Examine the exact code at the problematic lines
cat -n crates/vm/src/bytes_inner.rs | sed -n '1095,1145p'Repository: RustPython/RustPython
Length of output: 2181
🏁 Script executed:
#!/bin/bash
# Verify the call to s.as_str() at line 1127 - trace through the logic
cat -n crates/vm/src/builtins/str.rs | sed -n '437,443p'Repository: RustPython/RustPython
Length of output: 287
🏁 Script executed:
#!/bin/bash
# Verify as_str() panic behavior by checking the expect message context
cat -n crates/vm/src/builtins/str.rs | sed -n '464,467p'Repository: RustPython/RustPython
Length of output: 263
Using as_str() on surrogate-containing string will panic.
At line 1108, s.to_str() returns None when encoding has surrogates. Then at line 1127, s.as_str() is called on that same string, which calls .expect("str has surrogates") and panics. Use to_string_lossy() instead, as the "surrogateescape" handler correctly does at line 1129.
🤖 Prompt for AI Agents
In `@crates/vm/src/bytes_inner.rs` around lines 1107 - 1128, The code panics
because it calls s.as_str() on a Surrogate-containing OsString (s) after
s.to_str() returned None; update the branch inside match encoding.as_ref() (the
"ignore" | "replace" | "backslashreplace" arm) to avoid s.as_str() and instead
use a lossy conversion (e.g., s.to_string_lossy()) when producing the fallback
encoding string (keep using crate::codecs::DEFAULT_ENCODING when encoding is
None); ensure you still respect the errors variable and return
vm.new_unicode_encode_error where appropriate.
youknowone
left a comment
There was a problem hiding this comment.
Thanks! I need to understand better about Rust file changes. Please check the comments
There was a problem hiding this comment.
The changes in this file doesn't look directly related to email library.
Could you share what's the motivation and what is it exactly fixing?
Adding a test case under extra_test/snippets helps to understand it better.
Please open a separated PR for changes of bytes_decode. I have to research more about this to understand what's changing.
There was a problem hiding this comment.
The new code partially implements the second argument of the decode* function
Relevant Python3 documentation here
I'll open a new PR soon, with the changes (Plus a couple more; I'll probably just try and implement all cases)
There was a problem hiding this comment.
(The relevant test is test_invalid_character_in_charset btw, I just skipped the test)
There was a problem hiding this comment.
Nevermind, I'm definitely wrong somewhere 🤦. Taking a look into it further
9a5757c to
ced23c6
Compare
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.