2018-03-26 Long names on Windows

One of my unit test was failing due to a weird error in sphinx-gallery. The module could not write a file on Windows because its name was longer than 260 which still seems to be a limit of the system.


import sys
if sys.platform.startswith("win"):
    from ctypes.wintypes import MAX_PATH



The error was not always happening depending on the fact the unit test was run from a virtual python environment or not. It is difficult to predict that a name will fail for a specific installation on a specific platform. I forked sphinx-gallery and made the following modification. I don’t really like it as it should not be needed in the first place. I read this blog post Path Tool Long and discovered the following tool: winrmrf only means to delete very long files. In my case, the unit test fails because it tries to create a very long name. Other options than catching an exception would be to create a long filename in Windows or to add it to the souces.