Title: csv: csv.reader does not detect re-entrant iterator advancement · Issue #8323 · RustPython/RustPython · GitHub
Open Graph Title: csv: csv.reader does not detect re-entrant iterator advancement · Issue #8323 · RustPython/RustPython
X Title: csv: csv.reader does not detect re-entrant iterator advancement · Issue #8323 · RustPython/RustPython
Description: Feature When a csv.reader input iterator calls next() on the same reader from its own __next__() method, the inner call advances the reader. RustPython then allows the outer call to continue parsing with stale reader state instead of rai...
Open Graph Description: Feature When a csv.reader input iterator calls next() on the same reader from its own __next__() method, the inner call advances the reader. RustPython then allows the outer call to continue parsin...
X Description: Feature When a csv.reader input iterator calls next() on the same reader from its own __next__() method, the inner call advances the reader. RustPython then allows the outer call to continue parsin...
Opengraph URL: https://github.com/RustPython/RustPython/issues/8323
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"csv: csv.reader does not detect re-entrant iterator advancement","articleBody":"## Feature\n\nWhen a `csv.reader` input iterator calls `next()` on the same reader from its\nown `__next__()` method, the inner call advances the reader. RustPython then\nallows the outer call to continue parsing with stale reader state instead of\nraising `csv.Error` like CPython.\n\n```python\nimport csv\n\n\nclass ReentrantIterator:\n def __init__(self):\n self.reader = None\n self.index = 0\n\n def __iter__(self):\n return self\n\n def __next__(self):\n self.index += 1\n if self.index == 1:\n next(self.reader)\n return \"a,b\"\n if self.index == 2:\n return \"x\"\n raise StopIteration\n\n\niterator = ReentrantIterator()\nreader = csv.reader(iterator)\niterator.reader = reader\nprint(next(reader))\n\n# CPython main:\n# _csv.Error: iterator has already advanced the reader\n#\n# RustPython:\n# ['a', 'b']\n```\n\nCPython rejects the outer call once it detects that the re-entrant inner call\nhas already advanced the reader. This prevents the outer call from continuing\nwith parser state that no longer belongs to it.\n\n## Python Documentation or reference to CPython source code\n\n- https://github.com/python/cpython/issues/145105\n- https://github.com/python/cpython/pull/145106\n\n\u003csub\u003eDrafted with AI assistance (Codex).\u003c/sub\u003e","author":{"url":"https://github.com/widehyo1","@type":"Person","name":"widehyo1"},"datePublished":"2026-07-19T12:53:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/8323/RustPython/issues/8323"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7a83bba7-4bbd-2db2-959b-eaecc81321d2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D70E:3DF3AD:1A03A23:248CBEC:6A5FB3DA |
| html-safe-nonce | dd6db948aa4938407008f9745ee5664d928a8b6ede1cc735de72c4b2880ef345 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzBFOjNERjNBRDoxQTAzQTIzOjI0OENCRUM6NkE1RkIzREEiLCJ2aXNpdG9yX2lkIjoiMzgxODU5NjgxNTUzNDUzNTY0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e5de7297d94205553d0d2c4a57ac94c7804f21527f5f4038743851f0f6cf9646 |
| hovercard-subject-tag | issue:4922738056 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/RustPython/RustPython/8323/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bdffa6009c17fdb95bf949507f53d8197b656cb8b3212693b509c095c9f2d5e2/RustPython/RustPython/issues/8323 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bdffa6009c17fdb95bf949507f53d8197b656cb8b3212693b509c095c9f2d5e2/RustPython/RustPython/issues/8323 |
| og:image:alt | Feature When a csv.reader input iterator calls next() on the same reader from its own __next__() method, the inner call advances the reader. RustPython then allows the outer call to continue parsin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | widehyo1 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1ec7085bd7214c509393537f93bc21c48856549e31538b70bdb3cc4df7eb5f70 |
| turbo-cache-control | no-preview |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b0ff0ab699186747983f122c82d4ebc71a1c22b4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width