Title: `tarfile.TarFile.add()` does not normalize symlink targets on Windows · Issue #151669 · python/cpython · GitHub
Open Graph Title: `tarfile.TarFile.add()` does not normalize symlink targets on Windows · Issue #151669 · python/cpython
X Title: `tarfile.TarFile.add()` does not normalize symlink targets on Windows · Issue #151669 · python/cpython
Description: Bug report Bug description: In #138309 tarfile.TarFile.extract() has been modified to replace / in symlink targets with \ on Windows. I believe that the opposite normalization should be done in tarfile.TarFile.add(). I have noticed this ...
Open Graph Description: Bug report Bug description: In #138309 tarfile.TarFile.extract() has been modified to replace / in symlink targets with \ on Windows. I believe that the opposite normalization should be done in tar...
X Description: Bug report Bug description: In #138309 tarfile.TarFile.extract() has been modified to replace / in symlink targets with \ on Windows. I believe that the opposite normalization should be done in tar...
Opengraph URL: https://github.com/python/cpython/issues/151669
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`tarfile.TarFile.add()` does not normalize symlink targets on Windows","articleBody":"# Bug report\n\n### Bug description:\n\nIn #138309 `tarfile.TarFile.extract()` has been modified to replace `/` in symlink targets with `\\` on Windows. I believe that the opposite normalization should be done in `tarfile.TarFile.add()`.\n\nI have noticed this in a downstream project that extracts tar archives generated by `git dist`, adds some additional files, and recreates the archive. When the git repository contains a symbolic link, the repacked archive contains symbolic link with the wrong path separators.\n\nBefore #138309, the extracted symbolic links on Windows were not functional (I believe) but the repacked archive had the same content as the original one. After #138309, this is not true anymore.\n\n### CPython versions tested on:\n\n3.15\n\n### Operating systems tested on:\n\nWindows\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-151671\n* gh-153517\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/dnicolodi","@type":"Person","name":"dnicolodi"},"datePublished":"2026-06-18T18:41:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/151669/cpython/issues/151669"}
| 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:e169c24b-c04b-2d0b-ea92-a8ca5a6675fc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DA52:52373:1777D09:20671F6:6A55DED0 |
| html-safe-nonce | 85ba0786b94e813392848c495a40a141d02fd014d425fdde7b65f502dcce2bf0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTUyOjUyMzczOjE3NzdEMDk6MjA2NzFGNjo2QTU1REVEMCIsInZpc2l0b3JfaWQiOiIzNjkxNjkxMTEwNDQxNTQxMzI4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6dbfaf6a639732e441045568b1e5aa0d11c754967764e3e9bb4f3d957b596328 |
| hovercard-subject-tag | issue:4695083279 |
| 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/151669/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b45cd79c045f218e090948ec0cce123d10ab6a51ceded72a9f225919a57c41f1/python/cpython/issues/151669 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b45cd79c045f218e090948ec0cce123d10ab6a51ceded72a9f225919a57c41f1/python/cpython/issues/151669 |
| og:image:alt | Bug report Bug description: In #138309 tarfile.TarFile.extract() has been modified to replace / in symlink targets with \ on Windows. I believe that the opposite normalization should be done in tar... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dnicolodi |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| 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 | 3725c7f9b2a6e3a27ef57c5aed13428c0f65e045 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width