Title: gh-141314: Fix TextIOWrapper.tell() assertion failure with standalone carriage return by mohsinm-dev · Pull Request #141331 · python/cpython · GitHub
Open Graph Title: gh-141314: Fix TextIOWrapper.tell() assertion failure with standalone carriage return by mohsinm-dev · Pull Request #141331 · python/cpython
X Title: gh-141314: Fix TextIOWrapper.tell() assertion failure with standalone carriage return by mohsinm-dev · Pull Request #141331 · python/cpython
Description: Summary Fix assertion failure in io.TextIOWrapper.tell() when reading files ending with standalone \r Add comprehensive test case to prevent regression Add NEWS entry documenting the fix Root Cause The tell() optimization algorithm assumed buffered data would always be available when calculating position, but files ending with standalone \r create empty snapshots, causing assert(skip_back <= PyBytes_GET_SIZE(next_input)) to fail. Fix Added check to skip optimization when next_input is empty, preventing the assertion failure while maintaining correct position calculation. Test Plan Added test case test_tell_after_readline_with_cr in test_textio.py Verified fix handles standalone carriage returns correctly Confirmed all existing io tests still pass Built CPython with debug assertions enabled Issue: gh-141314
Open Graph Description: Summary Fix assertion failure in io.TextIOWrapper.tell() when reading files ending with standalone \r Add comprehensive test case to prevent regression Add NEWS entry documenting the fix Root Cau...
X Description: Summary Fix assertion failure in io.TextIOWrapper.tell() when reading files ending with standalone \r Add comprehensive test case to prevent regression Add NEWS entry documenting the fix Root Cau...
Opengraph URL: https://github.com/python/cpython/pull/141331
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c6200cd0-47bb-3bcf-74b8-a64d3523a740 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B804:1EE5:387DD6F:4ED0086:6A50245A |
| html-safe-nonce | b6466923783989026d4cc689128559a3a697b432fe5c4f32ac8b649450dd5857 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODA0OjFFRTU6Mzg3REQ2Rjo0RUQwMDg2OjZBNTAyNDVBIiwidmlzaXRvcl9pZCI6IjMzOTg2MTU2OTc2NDY5NTM1NjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6ec4fc7ab3006a414ee757d7409f83bbd5ec1b911f8d2af55801262f3c1df54b |
| hovercard-subject-tag | pull_request:2993336620 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/141331/files |
| twitter:image | https://avatars.githubusercontent.com/u/55545648?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/55545648?s=400&v=4 |
| og:image:alt | Summary Fix assertion failure in io.TextIOWrapper.tell() when reading files ending with standalone \r Add comprehensive test case to prevent regression Add NEWS entry documenting the fix Root Cau... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | a08040246389072795e3b4e7b33c6d9a0c564eee02e829a809326d67c418b069 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d1b91b18e7330fc458dfd824c61eaed7daa830d6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width