Shutil.move Rpython assertion error

Create issue
Issue #2895 resolved
Creation Elemental created an issue

If you use shutil.move and the resulting path name is too long, it will raise an Rpython error that will crash the entire interpreter instead of raising any kind of exception. Was really annoying to figure out when this happened in a really large script and would not print out any kind of traceback to tell me where the error was happening. It took quite a bit of debugging and testing to determine the line where the issue was occuring, and the fact that it was being caused by a file path being too long. Trying to manually do the copy outside of pypy told me the pathname was too long.

Comments (8)

  1. Armin Rigo

    Works for me (PyPy 6.0.0 on Arch Linux). The attached script gives the same exception on CPython 2.7.14 and on PyPy. Can you check how the attached script works for you? And if it works as it should (i.e. IOError: [Errno 36] File name too long:), then can you give more details about what you're doing instead? Ideally, we'd like a similar script but modified to crash PyPy.

  2. Armin Rigo
    import os
    import shutil
    longname = 'TEST-this-is-a-very-long-name-askldjsaksdjkladsjsdalksajsadaslkjsalsajawo8wsahiwsawksjasnkas'
    with open(longname, 'w') as f:
    path = '.'
    while True:
        os.mkdir(path + '/some_sub_directory')
        shutil.move(path + '/' + longname, path + '/some_sub_directory/' + longname)
        path += '/some_sub_directory'
  3. Creation Elemental reporter

    Like I said, I did a bunch of testing to ensure it was specifically shuttil trying to move something that caused it. What I did was move a folder that had many subfoulders which in turn had sub folders. I also did this on Windows 10, which I forgot to mention.

  4. Creation Elemental reporter

    I should also mention, in case it is relevant, that it occurred when copying files between drives. I never checked if it happened when copying files on the same drive.

  5. Armin Rigo

    Thanks for the traceback! The problem is in rpython.rlib.rposix.getfullpathname(), which is indeed a Windows-only function.

  6. Log in to comment