bpo-38112: compileall: Skip long path path on Windows if the path can't be created#16414
bpo-38112: compileall: Skip long path path on Windows if the path can't be created#16414encukou merged 4 commits intopython:masterfrom
Conversation
vstinner
left a comment
There was a problem hiding this comment.
Rather than creating a subdirectory of a fixing length (many_directories) at once, would it be possible to create subdirectories one by one until the path is long enough or until we get a "path too long" error?
For example, replace makedirs() with a loop and stop at the first error? So we could test a path which is longer than usual, even if we cannot create the full many_directories tree.
|
Ah! I found where I already had to do something similiar: https://bugs.python.org/issue37412 I got a similar error on Windows. I wrote a function which tries to create a "long path" piece by piece: Note: test_getcwd_long_path() has the constraint of needing to goes into this directory using os.chdir(). |
Also, actually run the test
|
Thanks, I'll look at your code |
|
Hm, this one has the constraint of needing to fit |
|
@vstinner, does this look reasonable? |
| # On Windows, a FileNotFoundError("The filename or extension | ||
| # is too long") is raised for long paths | ||
| if sys.platform == "win32": | ||
| break |
There was a problem hiding this comment.
Shouldn't this raise otherwise? Same for OSError below. Just curious.
There was a problem hiding this comment.
Oh, and I was wrapping my head around the reason it doesn't :D
|
OK, merging now to try fixing the buildbots. |
…'t be created (pythonGH-16414) This avoids the buildbot failure on Windows: ``` FileNotFoundError: [WinError 206] The filename or extension is too long: 'd:\\temp\\tmp5r3z438t\\long\\1\\2\\3\\4\\5\\6\\7\\8\\9\\10\\11\\12\\13\\14\\15\\16\\17\\18\\19\\20\\21\\22\\23\\24\\25\\26\\27\\28\\29\\30\\31\\32\\33\\34\\35\\36\\37\\38\\39\\40\\41\\42\\43\\44\\45\\46\\47\\48\\49\\50\\51\\52\\53\\54\\55\\56\\57\\58\\59\\60\\61\\62\\63\\64\\65\\66\\67\\68\\69\\70\\71\\72\\73\\74\\75\\76\\77\\78' ``` Creates a path that's long but avoids OS restrictions. https://bugs.python.org/issue38112
This avoids the buildbot failure on Windows:
This creates a path that's long but avoids OS restrictions.
https://bugs.python.org/issue38112
Automerge-Triggered-By: @encukou