Commit fe6dd19
committed
pythongh-141314: Fix TextIOWrapper.tell() assertion failure with standalone carriage return
When TextIOWrapper.tell() is called after reading a line that ends with a
standalone carriage return (\r), the tell optimization algorithm incorrectly
assumes there is buffered data to search through. This causes an assertion
failure when skip_back=1 exceeds the empty buffer size.
The fix detects when next_input is empty and skips the optimization phase,
falling back to the byte-by-byte decoding method which always works correctly.
This properly handles the architectural constraint that buffer optimization
cannot function without buffered data.1 parent d13ee0a commit fe6dd19
2 files changed
Lines changed: 29 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
689 | 707 | | |
690 | 708 | | |
691 | 709 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2844 | 2844 | | |
2845 | 2845 | | |
2846 | 2846 | | |
2847 | | - | |
2848 | | - | |
2849 | | - | |
2850 | | - | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
2851 | 2857 | | |
2852 | 2858 | | |
2853 | 2859 | | |
| |||
2870 | 2876 | | |
2871 | 2877 | | |
2872 | 2878 | | |
| 2879 | + | |
2873 | 2880 | | |
2874 | 2881 | | |
2875 | 2882 | | |
| |||
0 commit comments