René's URL Explorer Experiment


Title: io.TextIOWrapper.read does not flush the underlying write buffer when given a size argument · Issue #115059 · python/cpython · GitHub

Open Graph Title: io.TextIOWrapper.read does not flush the underlying write buffer when given a size argument · Issue #115059 · python/cpython

X Title: io.TextIOWrapper.read does not flush the underlying write buffer when given a size argument · Issue #115059 · python/cpython

Description: Bug report Bug description: As reported by the StackOverflow question: https://stackoverflow.com/questions/76142400/python-file-write-stuck-in-append-mode-when-read-has-byte-count-as-parameter In the code below, when f.read is not given ...

Open Graph Description: Bug report Bug description: As reported by the StackOverflow question: https://stackoverflow.com/questions/76142400/python-file-write-stuck-in-append-mode-when-read-has-byte-count-as-parameter In t...

X Description: Bug report Bug description: As reported by the StackOverflow question: https://stackoverflow.com/questions/76142400/python-file-write-stuck-in-append-mode-when-read-has-byte-count-as-parameter In t...

Opengraph URL: https://github.com/python/cpython/issues/115059

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"io.TextIOWrapper.read does not flush the underlying write buffer when given a size argument","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nAs reported by the StackOverflow question:\r\nhttps://stackoverflow.com/questions/76142400/python-file-write-stuck-in-append-mode-when-read-has-byte-count-as-parameter\r\n\r\nIn the code below, when `f.read` is not given an argument, the pending content in the write buffer gets flushed so the output is `***s is a line` as expected.\r\n```\r\nwith open(\"new.txt\", 'w+') as f:\r\n    f.write(\"this is a line\")\r\n\r\nwith open(\"new.txt\", 'r+') as f:\r\n    f.write(\"***\")\r\n    f.read()  # \u003c\u003c note here\r\n    f.seek(0)\r\n    print(f.read()) # outputs: ***s is a line\r\n```\r\nBut when `f.read` is given a size argument, it is apparent that the underlying write buffer is not flushed immediately, causing the pending content to be written at the end of the file, rendering an output of `this is a line***` instead:\r\n```\r\nwith open(\"new.txt\", 'w+') as f:\r\n    f.write(\"this is a line\")\r\n\r\nwith open(\"new.txt\", 'r+') as f:\r\n    f.write(\"***\")\r\n    f.read(1)  # \u003c\u003c note here\r\n    f.seek(0)\r\n    print(f.read()) # outputs: this is a line***\r\n```\r\nThis issue occurs only with the C implementation of `io.TextIOWrapper` since the code above would work as expected if it is prepended with:\r\n```\r\nfrom _pyio import open\r\n```\r\n\r\n### CPython versions tested on:\r\n\r\n3.8, 3.11\r\n\r\n### Operating systems tested on:\r\n\r\nLinux, Windows\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-115163\n* gh-115206\n* gh-115205\n* gh-115240\n* gh-115244\n* gh-115245\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/blhsing","@type":"Person","name":"blhsing"},"datePublished":"2024-02-06T03:28:42Z","url":"https://github.com/python/cpython/issues/115059"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:1da7ddee-2395-0d27-9cda-f7c6849091f1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB8EE:46358:2DB695:3BC36F:6B02335D
html-safe-nonceed6bc2b10824cb4fca6c31a4ad91a45e34650f59ad8ede367aac2e95b507aa50
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEVFOjQ2MzU4OjJEQjY5NTozQkMzNkY6NkIwMjMzNUQiLCJ2aXNpdG9yX2lkIjoiMTEyNjE3OTkwNjE0NTg5MTE2NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac581758c0b177ea0151b5fdece3f5f2af4de9addedec1b43a0de63829e3772930
hovercard-subject-tagissue:2119875587
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/115059/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a5ec224e75020290540753ef0d467ed5126927f54573b7a6ff025565d6f3d4cf/python/cpython/issues/115059
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a5ec224e75020290540753ef0d467ed5126927f54573b7a6ff025565d6f3d4cf/python/cpython/issues/115059
og:image:altBug report Bug description: As reported by the StackOverflow question: https://stackoverflow.com/questions/76142400/python-file-write-stuck-in-append-mode-when-read-has-byte-count-as-parameter In t...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameblhsing
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/115059#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F115059
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F115059
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/115059
Reloadhttps://github.com/python/cpython/issues/115059
Reloadhttps://github.com/python/cpython/issues/115059
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/115059
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/115059
io.TextIOWrapper.read does not flush the underlying write buffer when given a size argumenthttps://github.com/python/cpython/issues/115059#top
https://github.com/serhiy-storchaka
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
topic-IOhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-IO%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/blhsing
blhsinghttps://github.com/blhsing
on Feb 6, 2024https://github.com/python/cpython/issues/115059#issue-2119875587
https://stackoverflow.com/questions/76142400/python-file-write-stuck-in-append-mode-when-read-has-byte-count-as-parameterhttps://stackoverflow.com/questions/76142400/python-file-write-stuck-in-append-mode-when-read-has-byte-count-as-parameter
gh-115059: Flush the underlying write buffer in io.BufferedRandom.read1() #115163https://github.com/python/cpython/pull/115163
[3.11] gh-115059: Flush the underlying write buffer in io.BufferedRandom.read1() (GH-115163) #115206https://github.com/python/cpython/pull/115206
[3.12] gh-115059: Flush the underlying write buffer in io.BufferedRandom.read1() (GH-115163) #115205https://github.com/python/cpython/pull/115205
gh-115059: Remove debugging code in test_io #115240https://github.com/python/cpython/pull/115240
[3.12] gh-115059: Remove debugging code in test_io (GH-115240) #115244https://github.com/python/cpython/pull/115244
[3.11] gh-115059: Remove debugging code in test_io (GH-115240) #115245https://github.com/python/cpython/pull/115245
blhsinghttps://github.com/blhsing
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Feb 6, 2024https://github.com/python/cpython/issues/115059#event-11712475344
serhiy-storchakahttps://github.com/serhiy-storchaka
topic-IOhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-IO%22
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
on Feb 6, 2024https://github.com/python/cpython/issues/115059#event-11717116973
serhiy-storchakahttps://github.com/serhiy-storchaka
on Feb 7, 2024https://github.com/python/cpython/issues/115059#event-11731803164
serhiy-storchakahttps://github.com/serhiy-storchaka
on Feb 8, 2024https://github.com/python/cpython/issues/115059#event-11744366061
pythongh-115059: Flush the underlying write buffer in io.BufferedRand…https://github.com/serhiy-storchaka/cpython/commit/dfdee5595fe2c3c11f000d1677ea364097dc5e50
pythongh-115059https://github.com/python/cpython/issues/115059
dfdee55https://github.com/serhiy-storchaka/cpython/commit/dfdee5595fe2c3c11f000d1677ea364097dc5e50
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Feb 8, 2024https://github.com/python/cpython/issues/115059#issuecomment-1933900407
#115163https://github.com/python/cpython/pull/115163
serhiy-storchakahttps://github.com/serhiy-storchaka
on Feb 9, 2024https://github.com/python/cpython/issues/115059#event-11756363996
gh-115059: Flush the underlying write buffer in io.BufferedRandom.rea…https://github.com/python/cpython/commit/846fd721d518dda88a7d427ec3d2c03c45d9fa90
gh-115059https://github.com/python/cpython/issues/115059
846fd72https://github.com/python/cpython/commit/846fd721d518dda88a7d427ec3d2c03c45d9fa90
miss-islingtonhttps://github.com/miss-islington
on Feb 9, 2024https://github.com/python/cpython/issues/115059#event-11756365385
pythongh-115059: Flush the underlying write buffer in io.BufferedRand…https://github.com/miss-islington/cpython/commit/0123722677cc1dfc2327ab398e6ae67dc04d145f
pythongh-115059https://github.com/python/cpython/issues/115059
0123722https://github.com/miss-islington/cpython/commit/0123722677cc1dfc2327ab398e6ae67dc04d145f
pythongh-115059: Flush the underlying write buffer in io.BufferedRand…https://github.com/miss-islington/cpython/commit/42cb2f3cbcfd68c8bb12e61c276e16ec28be548e
pythongh-115059https://github.com/python/cpython/issues/115059
42cb2f3https://github.com/miss-islington/cpython/commit/42cb2f3cbcfd68c8bb12e61c276e16ec28be548e
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Feb 9, 2024https://github.com/python/cpython/issues/115059#issuecomment-1935697549
@blhsinghttps://github.com/blhsing
serhiy-storchakahttps://github.com/serhiy-storchaka
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Feb 9, 2024https://github.com/python/cpython/issues/115059#event-11756439224
serhiy-storchakahttps://github.com/serhiy-storchaka
on Feb 9, 2024https://github.com/python/cpython/issues/115059#event-11756577508
[3.12] gh-115059: Flush the underlying write buffer in io.BufferedRan…https://github.com/python/cpython/commit/0211f919b11c029d067769cae3f5e86068df85ce
gh-115059https://github.com/python/cpython/issues/115059
0211f91https://github.com/python/cpython/commit/0211f919b11c029d067769cae3f5e86068df85ce
[3.11] gh-115059: Flush the underlying write buffer in io.BufferedRan…https://github.com/python/cpython/commit/20c6535693acacd8136820a032dfcfd9d99a6f89
gh-115059https://github.com/python/cpython/issues/115059
20c6535https://github.com/python/cpython/commit/20c6535693acacd8136820a032dfcfd9d99a6f89
pythongh-115059: Remove debugging code in test_iohttps://github.com/serhiy-storchaka/cpython/commit/b5bf15b962529900428d937f629ca9188c6c380e
pythongh-115059https://github.com/python/cpython/issues/115059
b5bf15bhttps://github.com/serhiy-storchaka/cpython/commit/b5bf15b962529900428d937f629ca9188c6c380e
gh-115059: Remove debugging code in test_io (GH-115240)https://github.com/python/cpython/commit/597fad07f7bf709ac7084ac20aa3647995759b01
gh-115059https://github.com/python/cpython/issues/115059
GH-115240https://github.com/python/cpython/pull/115240
597fad0https://github.com/python/cpython/commit/597fad07f7bf709ac7084ac20aa3647995759b01
miss-islingtonhttps://github.com/miss-islington
on Feb 10, 2024https://github.com/python/cpython/issues/115059#event-11764818122
pythongh-115059: Remove debugging code in test_io (pythonGH-115240)https://github.com/miss-islington/cpython/commit/417b15c04f28f459b63d73bc2bf0b1b00071a4fe
pythongh-115059https://github.com/python/cpython/issues/115059
pythonGH-115240https://github.com/python/cpython/pull/115240
417b15chttps://github.com/miss-islington/cpython/commit/417b15c04f28f459b63d73bc2bf0b1b00071a4fe
pythongh-115059: Remove debugging code in test_io (pythonGH-115240)https://github.com/miss-islington/cpython/commit/f8db194e0f8e2dce28d1ce391ee95a232e613dc0
pythongh-115059https://github.com/python/cpython/issues/115059
pythonGH-115240https://github.com/python/cpython/pull/115240
f8db194https://github.com/miss-islington/cpython/commit/f8db194e0f8e2dce28d1ce391ee95a232e613dc0
serhiy-storchakahttps://github.com/serhiy-storchaka
on Feb 10, 2024https://github.com/python/cpython/issues/115059#event-11764893905
[3.11] gh-115059: Remove debugging code in test_io (GH-115240) (GH-11…https://github.com/python/cpython/commit/562fe5f5d411a9562f60313f71b924520a60eb9e
gh-115059https://github.com/python/cpython/issues/115059
GH-115240https://github.com/python/cpython/pull/115240
GH-11…https://github.com/python/cpython/pull/115245
562fe5fhttps://github.com/python/cpython/commit/562fe5f5d411a9562f60313f71b924520a60eb9e
[3.12] gh-115059: Remove debugging code in test_io (GH-115240) (GH-11…https://github.com/python/cpython/commit/a5f49ce65ef83c41c9cc87566fe59be766d0f3ca
gh-115059https://github.com/python/cpython/issues/115059
GH-115240https://github.com/python/cpython/pull/115240
GH-11…https://github.com/python/cpython/pull/115244
a5f49cehttps://github.com/python/cpython/commit/a5f49ce65ef83c41c9cc87566fe59be766d0f3ca
fsc-erikerhttps://github.com/fsc-eriker
on Feb 14, 2024https://github.com/python/cpython/issues/115059#event-11802565172
pythongh-115059: Flush the underlying write buffer in io.BufferedRand…https://github.com/fsc-eriker/cpython/commit/6df5d025cb20f55d0033d55772342534ced8d22b
pythongh-115059https://github.com/python/cpython/issues/115059
6df5d02https://github.com/fsc-eriker/cpython/commit/6df5d025cb20f55d0033d55772342534ced8d22b
pythongh-115059: Remove debugging code in test_io (pythonGH-115240)https://github.com/fsc-eriker/cpython/commit/7a5127acb53adcb55fcb390e1cb0fe8823e8ba90
pythongh-115059https://github.com/python/cpython/issues/115059
pythonGH-115240https://github.com/python/cpython/pull/115240
7a5127ahttps://github.com/fsc-eriker/cpython/commit/7a5127acb53adcb55fcb390e1cb0fe8823e8ba90
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/115059
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/115059
serhiy-storchakahttps://github.com/serhiy-storchaka
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
topic-IOhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-IO%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.