Skip to content

Commit e5bc4d8

Browse files
committed
fix
1 parent 2a4a638 commit e5bc4d8

File tree

5 files changed

+29
-27
lines changed

5 files changed

+29
-27
lines changed

Lib/test/test_io.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3815,6 +3815,7 @@ def __del__(self):
38153815
""".format(iomod=iomod, kwargs=kwargs)
38163816
return assert_python_ok("-c", code)
38173817

3818+
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError during module teardown in __del__
38183819
def test_create_at_shutdown_without_encoding(self):
38193820
rc, out, err = self._check_create_at_shutdown()
38203821
if err:
@@ -3824,6 +3825,7 @@ def test_create_at_shutdown_without_encoding(self):
38243825
else:
38253826
self.assertEqual("ok", out.decode().strip())
38263827

3828+
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError during module teardown in __del__
38273829
def test_create_at_shutdown_with_encoding(self):
38283830
rc, out, err = self._check_create_at_shutdown(encoding='utf-8',
38293831
errors='strict')

Lib/test/test_logging.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5165,6 +5165,7 @@ def __init__(self, name='MyLogger', level=logging.NOTSET):
51655165
h.close()
51665166
logging.setLoggerClass(logging.Logger)
51675167

5168+
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError during module teardown in __del__
51685169
def test_logging_at_shutdown(self):
51695170
# bpo-20037: Doing text I/O late at interpreter shutdown must not crash
51705171
code = textwrap.dedent("""
@@ -5184,6 +5185,7 @@ def __del__(self):
51845185
self.assertIn("exception in __del__", err)
51855186
self.assertIn("ValueError: some error", err)
51865187

5188+
@unittest.expectedFailure # TODO: RUSTPYTHON; AttributeError during module teardown in __del__
51875189
def test_logging_at_shutdown_open(self):
51885190
# bpo-26789: FileHandler keeps a reference to the builtin open()
51895191
# function to be able to open or reopen the file during Python

Lib/test/test_plistlib.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,6 @@ def test_non_bmp_characters(self):
752752
data = plistlib.dumps(pl, fmt=fmt)
753753
self.assertEqual(plistlib.loads(data), pl)
754754

755-
@unittest.expectedFailure # TODO: RUSTPYTHON
756755
def test_lone_surrogates(self):
757756
for fmt in ALL_FORMATS:
758757
with self.subTest(fmt=fmt):

Lib/test/test_str.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2287,7 +2287,6 @@ def test_codecs_errors(self):
22872287
self.assertRaises(ValueError, complex, "\ud800")
22882288
self.assertRaises(ValueError, complex, "\udf00")
22892289

2290-
@unittest.expectedFailure # TODO: RUSTPYTHON
22912290
def test_codecs(self):
22922291
# Encoding
22932292
self.assertEqual('hello'.encode('ascii'), b'hello')

crates/common/src/encodings.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,9 @@ pub mod utf7 {
688688

689689
let mut out = Wtf8Buf::with_capacity(size);
690690
let mut in_shift = false;
691-
let mut bitsleft: u32 = 0;
692-
let mut charsleft: u64 = 0;
693-
let mut startinpos: usize = 0;
691+
let mut bits_left: u32 = 0;
692+
let mut chars_left: u64 = 0;
693+
let mut shift_start: usize = 0;
694694
let mut out_len_at_shift_start: usize = 0;
695695
let mut high_surrogate: u32 = 0;
696696
let mut i = 0;
@@ -701,14 +701,14 @@ pub mod utf7 {
701701
if in_shift {
702702
if is_b64_char(ch) {
703703
// Accumulate base64 bits
704-
charsleft = (charsleft << 6) | ub64(ch) as u64;
705-
bitsleft += 6;
704+
chars_left = (chars_left << 6) | ub64(ch) as u64;
705+
bits_left += 6;
706706
i += 1;
707707

708708
// Decode complete characters inline
709-
while bitsleft >= 16 {
710-
let out_ch = ((charsleft >> (bitsleft - 16)) & 0xffff) as u32;
711-
bitsleft -= 16;
709+
while bits_left >= 16 {
710+
let out_ch = ((chars_left >> (bits_left - 16)) & 0xffff) as u32;
711+
bits_left -= 16;
712712

713713
if high_surrogate != 0 {
714714
if (0xdc00..=0xdfff).contains(&out_ch) {
@@ -741,31 +741,31 @@ pub mod utf7 {
741741
} else {
742742
// End of shift sequence
743743
in_shift = false;
744-
let endinpos = i + 1; // past the terminator
744+
let shift_end = i + 1; // past the terminator
745745
i += 1;
746746

747747
// Check for errors in the shift sequence
748-
if bitsleft >= 6 {
748+
if bits_left >= 6 {
749749
// Partial character in shift sequence
750750
high_surrogate = 0;
751751
let replace = ctx.handle_error(
752752
errors,
753-
startinpos..endinpos,
753+
shift_start..shift_end,
754754
Some("partial character in shift sequence"),
755755
)?;
756756
out.push_wtf8(replace.as_ref());
757757
i = ctx.position();
758758
continue;
759759
}
760760

761-
if bitsleft > 0
762-
&& (charsleft & ((1u64 << bitsleft) - 1)) != 0
761+
if bits_left > 0
762+
&& (chars_left & ((1u64 << bits_left) - 1)) != 0
763763
{
764764
// Non-zero padding bits
765765
high_surrogate = 0;
766766
let replace = ctx.handle_error(
767767
errors,
768-
startinpos..endinpos,
768+
shift_start..shift_end,
769769
Some("non-zero padding bits in shift sequence"),
770770
)?;
771771
out.push_wtf8(replace.as_ref());
@@ -774,10 +774,10 @@ pub mod utf7 {
774774
}
775775

776776
// Check for ill-formed (empty shift with non-dash terminator)
777-
if i == startinpos + 2 && ch != b'-' {
777+
if i == shift_start + 2 && ch != b'-' {
778778
let replace = ctx.handle_error(
779779
errors,
780-
startinpos..endinpos,
780+
shift_start..shift_end,
781781
Some("ill-formed sequence"),
782782
)?;
783783
out.push_wtf8(replace.as_ref());
@@ -812,7 +812,7 @@ pub mod utf7 {
812812
}
813813
}
814814
} else if ch == b'+' {
815-
startinpos = i;
815+
shift_start = i;
816816
out_len_at_shift_start = out.len();
817817
i += 1;
818818
if i < size && data[i] == b'-' {
@@ -821,8 +821,8 @@ pub mod utf7 {
821821
out.push_char('+');
822822
} else {
823823
in_shift = true;
824-
bitsleft = 0;
825-
charsleft = 0;
824+
bits_left = 0;
825+
chars_left = 0;
826826
}
827827
} else if is_special(ch) {
828828
let replace = ctx.handle_error(
@@ -842,23 +842,23 @@ pub mod utf7 {
842842
if in_shift {
843843
if final_decode {
844844
// Check if there's a problem with the unterminated shift
845-
let has_error = bitsleft >= 6
846-
|| (bitsleft > 0
847-
&& (charsleft & ((1u64 << bitsleft) - 1)) != 0)
845+
let has_error = bits_left >= 6
846+
|| (bits_left > 0
847+
&& (chars_left & ((1u64 << bits_left) - 1)) != 0)
848848
|| high_surrogate != 0;
849849
if has_error {
850850
let replace = ctx.handle_error(
851851
errors,
852-
startinpos..size,
852+
shift_start..size,
853853
Some("unterminated shift sequence"),
854854
)?;
855855
out.push_wtf8(replace.as_ref());
856856
}
857-
// If no error (bitsleft < 6, zero padding, no surrogate), just consume
857+
// If no error (bits_left < 6, zero padding, no surrogate), just consume
858858
} else {
859859
// Non-final: truncate output to before the shift, report consumed
860860
out.truncate(out_len_at_shift_start);
861-
return Ok((out, startinpos));
861+
return Ok((out, shift_start));
862862
}
863863
}
864864

0 commit comments

Comments
 (0)