Title: `Path.move()` fails to change the case on macOS · Issue #162377 · python/cpython · GitHub
Open Graph Title: `Path.move()` fails to change the case on macOS · Issue #162377 · python/cpython
X Title: `Path.move()` fails to change the case on macOS · Issue #162377 · python/cpython
Description: Bug report import os, shutil from pathlib import Path Path('readme.txt').touch() os.rename('readme.txt', 'README.txt') print(os.listdir()) Path('README.txt').rename('readme.txt') print(os.listdir()) shutil.move('readme.txt', 'README.txt'...
Open Graph Description: Bug report import os, shutil from pathlib import Path Path('readme.txt').touch() os.rename('readme.txt', 'README.txt') print(os.listdir()) Path('README.txt').rename('readme.txt') print(os.listdir()...
X Description: Bug report import os, shutil from pathlib import Path Path('readme.txt').touch() os.rename('readme.txt', 'README.txt') print(os.listdir()) Path('README.txt').rename(...
Opengraph URL: https://github.com/python/cpython/issues/162377
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`Path.move()` fails to change the case on macOS","articleBody":"### Bug report\n\n\n```python\nimport os, shutil\nfrom pathlib import Path\n\nPath('readme.txt').touch()\n\nos.rename('readme.txt', 'README.txt')\nprint(os.listdir())\n\nPath('README.txt').rename('readme.txt')\nprint(os.listdir())\n\nshutil.move('readme.txt', 'README.txt')\nprint(os.listdir())\n\nos.replace('README.txt', 'readme.txt')\nprint(os.listdir())\n\nPath('readme.txt').move('README.txt')\nprint(os.listdir())\n```\n\n```bash\n2026-11-21T11:23:56.958254000+0100 maurycy@gimel /tmp/p % uv run --python 3.15 python repro.py\n['repro.py', 'README.txt']\n['repro.py', 'readme.txt']\n['repro.py', 'README.txt']\n['repro.py', 'readme.txt']\nTraceback (most recent call last):\n File \"/private/tmp/p/repro.py\", line 18, in \u003cmodule>\n Path('readme.txt').move('README.txt')\n ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^\n File \"/Users/maurycy/.local/share/uv/python/cpython-3.15.2-macos-aarch64-none/lib/python3.15/pathlib/__init__.py\", line 1382, in move\n ensure_different_files(self, target)\n ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^\n File \"/Users/maurycy/.local/share/uv/python/cpython-3.15.2-macos-aarch64-none/lib/python3.15/pathlib/_os.py\", line 303, in ensure_different_files\n raise err\nOSError: [Errno 22] Source and target are the same file: 'readme.txt' -> 'README.txt'\n[1] 2026-11-21T11:23:57.245817000+0100 maurycy@gimel /tmp/p % \n```\n\nI guess it likely happens on all case-insensitive filesystems.\n\nThere's an explicit exception for this in `shutil.move()`:\n\nhttps://github.com/python/cpython/blob/e0d0f2e153450cf79b84e2ec5ffbcbad8aea7922/Lib/shutil.py#L944-L948\n\nI think this is a good first time issue.\n\nI will not immediately be working on this one.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS","author":{"url":"https://github.com/maurycy","@type":"Person","name":"maurycy"},"datePublished":"2026-11-21T10:16:54Z","url":"https://github.com/python/cpython/issues/162377"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:00621489-d38a-7ace-200c-e4045b11b10c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC6E:B53AF:310AFBE:4154359:6B01E93B |
| html-safe-nonce | 69f0f26aeba933dcd14ee13bf4eeb8c4dbea0c80f51331fe2716ab9f012045b2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzZFOkI1M0FGOjMxMEFGQkU6NDE1NDM1OTo2QjAxRTkzQiIsInZpc2l0b3JfaWQiOiI4MzU5Nzg5NjA4NzU3NzUwMDc1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7b653152c446619071e37dbd1050877e0064bca9f30ee42f7ff915895625630f |
| hovercard-subject-tag | issue:6527532127 |
| 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/python/cpython/162377/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2bc3b252845bdf27ba611b590f72de1ee96058c3fe0b87ca75221c6afb73f42d/python/cpython/issues/162377 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2bc3b252845bdf27ba611b590f72de1ee96058c3fe0b87ca75221c6afb73f42d/python/cpython/issues/162377 |
| og:image:alt | Bug report import os, shutil from pathlib import Path Path('readme.txt').touch() os.rename('readme.txt', 'README.txt') print(os.listdir()) Path('README.txt').rename('readme.txt') print(os.listdir()... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | maurycy |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width