René's URL Explorer Experiment


Title: gh-143968: Prevent pathlib.Path.copy() from processing special files (FIFO, devices) by tonghuaroot · Pull Request #143966 · python/cpython · GitHub

Open Graph Title: gh-143968: Prevent pathlib.Path.copy() from processing special files (FIFO, devices) by tonghuaroot · Pull Request #143966 · python/cpython

X Title: gh-143968: Prevent pathlib.Path.copy() from processing special files (FIFO, devices) by tonghuaroot · Pull Request #143966 · python/cpython

Description: Closes gh-143968 [3.14] gh-143968: Prevent pathlib.Path.copy() from processing special files (FIFO, devices) Description This PR addresses an issue where pathlib.Path.copy() (introduced for 3.14) could indiscriminately attempt to open and read from special files like FIFOs (named pipes) or character devices (e.g., /dev/zero). The Problem FIFOs: Reading from a FIFO without a writer blocks indefinitely, causing the Python process to hang. Infinite Sources: Reading from /dev/zero results in an infinite loop that continues until disk space is exhausted or the process is killed. The Fix The copy logic in _copy_from inside Lib/pathlib/__init__.py has been modified to explicitly check is_file() before attempting to copy content. If the source is a regular file, it proceeds as normal. If it is a directory (already handled), it recurses. New Behavior: If it is a special file (but exists), it raises io.UnsupportedOperation. This aligns with shutil.copyfile's philosophy of safely handling special files by refusing to copy them as streams. Existing behavior for dangling symlinks (raising FileNotFoundError) is strictly preserved. Tests Added new test cases in Lib/test/test_pathlib/test_copy.py to cover these scenarios: test_copy_fifo: Verifies that copying a FIFO (created via os.mkfifo) raises UnsupportedOperation immediately instead of blocking. test_copy_char_device: Verifies that copying a character device (e.g., /dev/null) raises UnsupportedOperation. Validation Ran python -m test test_pathlib locally and all 1375 tests passed. Issue: gh-143968

Open Graph Description: Closes gh-143968 [3.14] gh-143968: Prevent pathlib.Path.copy() from processing special files (FIFO, devices) Description This PR addresses an issue where pathlib.Path.copy() (introduced for 3.14) c...

X Description: Closes gh-143968 [3.14] gh-143968: Prevent pathlib.Path.copy() from processing special files (FIFO, devices) Description This PR addresses an issue where pathlib.Path.copy() (introduced for 3.14) c...

Opengraph URL: https://github.com/python/cpython/pull/143966

X: @github

direct link

Domain: patch-diff.githubusercontent.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:bddc129c-efd1-2e7d-703a-14048306d1d3
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id89D8:20C3D6:C87D4B:108ABE7:696EE59E
html-safe-nonce92c9c605b95eea553d692e6bacd0102d021173e86ef41cc087b491033623afd3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OUQ4OjIwQzNENjpDODdENEI6MTA4QUJFNzo2OTZFRTU5RSIsInZpc2l0b3JfaWQiOiIyODU4MzQxMjk0NjMzMDUxNTUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmace7960c16bfac3d8aaba528bcd90be918577a6907614c129e881f56695d0fff51
hovercard-subject-tagpull_request:3184226343
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/143966/files
twitter:imagehttps://avatars.githubusercontent.com/u/23011166?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/23011166?s=400&v=4
og:image:altCloses gh-143968 [3.14] gh-143968: Prevent pathlib.Path.copy() from processing special files (FIFO, devices) Description This PR addresses an issue where pathlib.Path.copy() (introduced for 3.14) c...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb278ad162d35332b6de714dfb005de04386c4d92df6475522bef910f491a35ee
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release39aed5006635ab6f45e6b77d23e73b08a00272a3
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F143966%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F143966%2Ffiles
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files
Reloadhttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files
Reloadhttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files
python https://patch-diff.githubusercontent.com/python
cpythonhttps://patch-diff.githubusercontent.com/python/cpython
Please reload this pagehttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://patch-diff.githubusercontent.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://patch-diff.githubusercontent.com/login?return_to=%2Fpython%2Fcpython
Code https://patch-diff.githubusercontent.com/python/cpython
Issues 5k+ https://patch-diff.githubusercontent.com/python/cpython/issues
Pull requests 2.1k https://patch-diff.githubusercontent.com/python/cpython/pulls
Actions https://patch-diff.githubusercontent.com/python/cpython/actions
Projects 31 https://patch-diff.githubusercontent.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://patch-diff.githubusercontent.com/python/cpython/security
Please reload this pagehttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files
Insights https://patch-diff.githubusercontent.com/python/cpython/pulse
Code https://patch-diff.githubusercontent.com/python/cpython
Issues https://patch-diff.githubusercontent.com/python/cpython/issues
Pull requests https://patch-diff.githubusercontent.com/python/cpython/pulls
Actions https://patch-diff.githubusercontent.com/python/cpython/actions
Projects https://patch-diff.githubusercontent.com/python/cpython/projects
Security https://patch-diff.githubusercontent.com/python/cpython/security
Insights https://patch-diff.githubusercontent.com/python/cpython/pulse
Sign up for GitHub https://patch-diff.githubusercontent.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://patch-diff.githubusercontent.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
tonghuaroothttps://patch-diff.githubusercontent.com/tonghuaroot
python:mainhttps://patch-diff.githubusercontent.com/python/cpython/tree/main
tonghuaroot:fix-pathlib-copy-fifohttps://patch-diff.githubusercontent.com/tonghuaroot/cpython/tree/fix-pathlib-copy-fifo
Conversation 5 https://patch-diff.githubusercontent.com/python/cpython/pull/143966
Commits 7 https://patch-diff.githubusercontent.com/python/cpython/pull/143966/commits
Checks 43 https://patch-diff.githubusercontent.com/python/cpython/pull/143966/checks
Files changed 3 https://patch-diff.githubusercontent.com/python/cpython/pull/143966/files
gh-143968: Prevent pathlib.Path.copy() from processing special files (FIFO, devices) https://patch-diff.githubusercontent.com/python/cpython/pull/143966/files#top
Show all changes 7 commits https://patch-diff.githubusercontent.com/python/cpython/pull/143966/files
40fee16 [pathlib] Prevent Path.copy() from processing special files tonghuaroot Jan 17, 2026 https://patch-diff.githubusercontent.com/python/cpython/pull/143966/commits/40fee16093171f283c7feaa5a0a39b8d6dbc1994
35f7ecc Merge branch 'main' into fix-pathlib-copy-fifo tonghuaroot Jan 17, 2026 https://patch-diff.githubusercontent.com/python/cpython/pull/143966/commits/35f7ecc20ab372e32bbed347874cf3a2c7a395c3
f3d9d25 Fix trailing whitespace checks tonghuaroot Jan 17, 2026 https://patch-diff.githubusercontent.com/python/cpython/pull/143966/commits/f3d9d25080b66f8d4899af5170e82221d81252b3
895527c Fix lint: remove unused import os tonghuaroot Jan 17, 2026 https://patch-diff.githubusercontent.com/python/cpython/pull/143966/commits/895527c948aade8c55e6291e31057f47197c9944
3e9c566 📜🤖 Added by blurb_it. blurb-it[bot] Jan 17, 2026 https://patch-diff.githubusercontent.com/python/cpython/pull/143966/commits/3e9c566b43cb21ebee74191d51062a22d9dbf705
1408b79 Merge branch 'main' into fix-pathlib-copy-fifo tonghuaroot Jan 17, 2026 https://patch-diff.githubusercontent.com/python/cpython/pull/143966/commits/1408b799551cd6dc4d1e02b2986b5e40bf92c29a
e38a795 Merge branch 'main' into fix-pathlib-copy-fifo tonghuaroot Jan 18, 2026 https://patch-diff.githubusercontent.com/python/cpython/pull/143966/commits/e38a795f45f1f6f450737a3926f2259d4c163f5d
Clear filters https://patch-diff.githubusercontent.com/python/cpython/pull/143966/files
Please reload this pagehttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files
Please reload this pagehttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files
__init__.py https://patch-diff.githubusercontent.com/python/cpython/pull/143966/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
test_copy.py https://patch-diff.githubusercontent.com/python/cpython/pull/143966/files#diff-a851c246ff7ee2b99ab0a87aaa631eb6cc0c16a17fad77817733bc8969edd02e
2026-01-17-15-49-04.gh-issue-143968.5R_yPR.rst https://patch-diff.githubusercontent.com/python/cpython/pull/143966/files#diff-ebf981b48ef10eda88d61579d24cb8b705265ccdcf54d81da943ad8186d6cae6
https://patch-diff.githubusercontent.com/python/cpython/blob/main/.github/CODEOWNERS#L526
Lib/pathlib/__init__.pyhttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
View file https://patch-diff.githubusercontent.com/python/cpython/blob/e38a795f45f1f6f450737a3926f2259d4c163f5d/Lib/pathlib/__init__.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/python/cpython/pull/143966/{{ revealButtonHref }}
https://patch-diff.githubusercontent.com/python/cpython/pull/143966/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
https://patch-diff.githubusercontent.com/python/cpython/pull/143966/files#diff-2282b1d4074c3cc317f8490ac16730aef232a3a125b8acfc49232dcd6c4f6d88
https://patch-diff.githubusercontent.com/python/cpython/blob/main/.github/CODEOWNERS#L527
Lib/test/test_pathlib/test_copy.pyhttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files#diff-a851c246ff7ee2b99ab0a87aaa631eb6cc0c16a17fad77817733bc8969edd02e
View file https://patch-diff.githubusercontent.com/python/cpython/blob/e38a795f45f1f6f450737a3926f2259d4c163f5d/Lib/test/test_pathlib/test_copy.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/python/cpython/pull/143966/{{ revealButtonHref }}
https://patch-diff.githubusercontent.com/python/cpython/pull/143966/files#diff-a851c246ff7ee2b99ab0a87aaa631eb6cc0c16a17fad77817733bc8969edd02e
Misc/NEWS.d/next/Library/2026-01-17-15-49-04.gh-issue-143968.5R_yPR.rsthttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files#diff-ebf981b48ef10eda88d61579d24cb8b705265ccdcf54d81da943ad8186d6cae6
View file https://patch-diff.githubusercontent.com/python/cpython/blob/e38a795f45f1f6f450737a3926f2259d4c163f5d/Misc/NEWS.d/next/Library/2026-01-17-15-49-04.gh-issue-143968.5R_yPR.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/python/cpython/pull/143966/{{ revealButtonHref }}
Please reload this pagehttps://patch-diff.githubusercontent.com/python/cpython/pull/143966/files
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.