Shutil.move Rpython assertion error

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:
        pass
    
    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. Log in to comment