~sschwarzer/ftputil#153: 
Infinite recursion in `FTPHost.stat`

From Simon Cox:

I'm getting infinite recursion with a host.stat call. The path._is_file_system_entity is called by stat, and then calls stat. ftputils v5.0.4 on Python 3.7 on Windows. Stack trace below:

Traceback (most recent call last):
  File "[my module].py", line 40, in <module>
    [my code]
  File "C:\Users\[username]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ftputil\host.py",
line 1017, in stat
    return self._stat._stat(path, _exception_for_missing_path)
  File "C:\Users\[username]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ftputil\stat.py",
line 846, in _stat
    self._real_stat, path, _exception_for_missing_path
  File "C:\Users\[username]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ftputil\stat.py",
line 801, in __call_with_parser_retry
    result = method(*args, **kwargs)
  File "C:\Users\[username]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ftputil\stat.py",
line 768, in _real_stat
    lstat_result = self._real_lstat(path, _exception_for_missing_path)
  File "C:\Users\[username]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ftputil\stat.py",
line 719, in _real_lstat
    if not self._path.isdir(dirname) and not _exception_for_missing_path:
  File "C:\Users\[username]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ftputil\path.py",
line 154, in isdir
    return self._is_file_system_entity(path, "dir")
  File "C:\Users\[username]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ftputil\path.py",
line 132, in _is_file_system_entity
    stat_result = self._host.stat(path, _exception_for_missing_path=False)
  File "C:\Users\[username]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ftputil\host.py",
line 1017, in stat
    return self._stat._stat(path, _exception_for_missing_path)
...
RecursionError: maximum recursion depth exceeded
Status
REPORTED
Submitter
~sschwarzer
Assigned to
No-one
Submitted
2 years ago
Updated
2 years ago
Labels
No labels applied.

~sschwarzer 2 years ago

I haven't seen this issue in the automated ftputil tests, which contain several lstat/stat tests, and the issue hasn't been reported otherwise. Therefore, I think it's something special with your environment.

I'm not sure what's causing this. Maybe a Windows junction?

Can you find out more about the situation? For example, can you modify the ftputil code to print the path arguments in the calls? You can use something like print(f"=== _Stat._stat: {path!r}") to distinguish calls in different methods. Note that the path arguments may not be the same in the different methods.

Register here or Log in to comment, or comment via email.