Title: Tests: error "tests may fail, unable to create temporary directory (...): [WinError 3] The system cannot find the path specified" on Windows · Issue #146202 · python/cpython · GitHub
Open Graph Title: Tests: error "tests may fail, unable to create temporary directory (...): [WinError 3] The system cannot find the path specified" on Windows · Issue #146202 · python/cpython
X Title: Tests: error "tests may fail, unable to create temporary directory (...): [WinError 3] The system cannot find the path specified" on Windows · Issue #146202 · python/cpython
Description: Windows CI failure: test_itertools corrupts Unicode temp directory name under mbcs encoding, breaks subsequent tests Summary On Windows (official Azure CI), the CPython 3.15 test suite produces cascading failures originating from test_it...
Open Graph Description: Windows CI failure: test_itertools corrupts Unicode temp directory name under mbcs encoding, breaks subsequent tests Summary On Windows (official Azure CI), the CPython 3.15 test suite produces cas...
X Description: Windows CI failure: test_itertools corrupts Unicode temp directory name under mbcs encoding, breaks subsequent tests Summary On Windows (official Azure CI), the CPython 3.15 test suite produces cas...
Opengraph URL: https://github.com/python/cpython/issues/146202
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Tests: error \"tests may fail, unable to create temporary directory (...): [WinError 3] The system cannot find the path specified\" on Windows","articleBody":"# Windows CI failure: `test_itertools` corrupts Unicode temp directory name under `mbcs` encoding, breaks subsequent tests\n\n## Summary\n\nOn Windows (official Azure CI), the CPython 3.15 test suite produces cascading failures originating from `test_itertools`. The test creates a temporary directory whose name contains a non-ASCII character. Because the Windows default filesystem encoding is `mbcs`, the Unicode byte sequence is misinterpreted and the directory name becomes corrupted on disk. The directory is never cleaned up, which causes all subsequent tests that create temporary directories to fail with `FileNotFoundError`.\n\n---\n\n## CPython Version\n\n```\nPython 3.15.0a7 (main branch)\n```\n\n## Operating System / Platform\n\n```\nWindows (Azure Pipelines Microsoft-hosted runner)\n```\n\n## Filesystem Encoding\n\n```python\n\u003e\u003e\u003e import sys\n\u003e\u003e\u003e sys.getfilesystemencoding()\n'mbcs'\n```\n\n---\n\n## CI Pipeline Context\n\n**Build step:**\n```\nPCbuild\\build.bat -e $(buildOpt)\n```\n\n**Test step:**\n```\nPCbuild\\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 \\\n --junit-xml=\"$(Build.BinariesDirectory)\\test-results.xml\" \\\n --tempdir=\"$(Build.BinariesDirectory)\\test\"\n```\n\n**Azure DevOps build log:**\nhttps://dev.azure.com/Python/cpython/_build/results?buildId=168864\u0026view=logs\u0026j=c8a71634-e5ec-54a0-3958-760f4148b765\u0026t=ddcdae4e-111a-5c2a-2289-6b784c553924\n\n---\n\n## Steps to Reproduce\n\n1. Check out the CPython `main` branch.\n2. Build on Windows:\n ```\n PCbuild\\build.bat -e \u003cbuildOpt\u003e\n ```\n3. Run the test suite:\n ```\n PCbuild\\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 ^\n -j0 --tempdir=\"%TEMP%\"\n ```\n4. Observe a directory with a corrupted name (e.g. `packageæ/`) left behind in the temp directory.\n5. Observe that subsequent tests fail with `FileNotFoundError`.\n\n---\n\n## Expected Behavior\n\n- All tests pass cleanly on Windows during CI builds.\n- No test leaves behind artifacts that interfere with other tests.\n- Test isolation is preserved — temporary directories are created and removed correctly.\n- Unicode filenames are handled consistently regardless of platform filesystem encoding.\n\n---\n\n## Actual Behavior\n\n- `test_itertools` creates a directory whose name contains a non-ASCII character (e.g. `æ`).\n- Under the Windows default codepage (`mbcs`), the Unicode name is misinterpreted: `æ` (U+00E6) is stored as `æ`.\n- The corrupted directory is **not removed** after `test_itertools` completes.\n- Subsequent tests (e.g. `test_class`, `test_pdb`) fail when attempting to create temporary directories because the corrupted entry causes `os_helper.temp_dir` to raise `FileNotFoundError`.\n- The runner reports a warning for `test_itertools` and marks unrelated tests as failed, significantly increasing triage cost.\n\n---\n\n## Relevant Log Excerpt\n\nFrom Azure build 168864:\n\n```\nWarning -- files was modified by test_itertools\nAfter: ... 'packageæ/'\n\ntest_class failed (env changed)\nFileNotFoundError: [WinError 3] unable to create temporary directory:\n'D:\\a\\1\\s\\build\\test_python_9140æ'\n```\n\n---\n\n## Root Cause (Analysis)\n\nTwo independent problems combine to produce this failure:\n\n**1. Encoding mismatch in `test_itertools`**\n\nThe test constructs or receives a directory name containing a non-ASCII character. On Windows, `sys.getfilesystemencoding()` returns `'mbcs'` rather than `'utf-8'`. The UTF-8 byte sequence for `æ` (`0xC3 0xA6`) is reinterpreted under the ANSI code page as two separate characters, producing the visible corruption `æ`. This is a violation of cross-platform Unicode path handling requirements.\n\n**2. Missing cleanup in `test_itertools`**\n\nThe test creates the directory but does not register it for cleanup (e.g. via `addCleanup`, `self.addCleanup`, or a context manager such as `tempfile.TemporaryDirectory`). The corrupted directory persists in the shared `--tempdir` location for the duration of the entire test run, causing every subsequent call to `os_helper.temp_dir` to fail with `WinError 3`.\n\n---\n\n## Impact\n\n| Area | Description | Severity |\n|---|---|---|\n| CI pipeline stability | All Windows builds fail after `test_itertools` runs | **High** |\n| Test isolation | Subsequent tests inherit corrupted filesystem state | **High** |\n| Unicode correctness | Non-ASCII filenames silently corrupted on Windows | **Medium** |\n| Triage cost | Unrelated failures obscure the root cause | **Medium** |\n| Local Windows dev | Developers running the full suite locally may be affected | **Low** |\n\n---\n\n## Files Involved\n\n- `Lib/test/test_itertools.py` — primary location of the encoding issue and missing cleanup\n- `Lib/test/support/os_helper.py` — secondary impact point (`temp_dir` context manager)\n\n---\n\n## Linked Resources\n\n- Azure DevOps build 168864: https://dev.azure.com/Python/cpython/_build/results?buildId=168864\n- PEP 529 — Change Windows filesystem encoding to UTF-8: https://peps.python.org/pep-0529/\n- `sys.getfilesystemencoding()` docs: https://docs.python.org/3/library/sys.html#sys.getfilesystemencoding\n- `os.fsencode()` docs: https://docs.python.org/3/library/os.html#os.fsencode\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-146347\n* gh-146349\n* gh-146350\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/Aasyaco","@type":"Person","name":"Aasyaco"},"datePublished":"2026-03-20T11:15:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/146202/cpython/issues/146202"}
| 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:e1ecb12e-8241-f03a-2cd4-32ed8583dce6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED9C:287EA1:1E7FA67:2B7E41D:6A50E6EA |
| html-safe-nonce | 65811decb7ba49ae844df149c5ed6400f2b10c99b804f0be2b8d7b0f40413a89 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDlDOjI4N0VBMToxRTdGQTY3OjJCN0U0MUQ6NkE1MEU2RUEiLCJ2aXNpdG9yX2lkIjoiNjY4OTE2NDQ3NTgzNTE0ODAxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a06f961ce4c76802d2df04fa8ad062c7a77a74dd4ce2ef56d3de86879bc688b3 |
| hovercard-subject-tag | issue:4107288910 |
| 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/146202/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ab7d4b020696575c382100848ea67dc6d246b989452684e5c6156f23c3baa847/python/cpython/issues/146202 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ab7d4b020696575c382100848ea67dc6d246b989452684e5c6156f23c3baa847/python/cpython/issues/146202 |
| og:image:alt | Windows CI failure: test_itertools corrupts Unicode temp directory name under mbcs encoding, breaks subsequent tests Summary On Windows (official Azure CI), the CPython 3.15 test suite produces cas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Aasyaco |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| 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 | fb19d617b534959801b4b7453938ecf1dfa22131 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width