[issue46084] Python 3.9.6 scan_dir returns filenotfound on long paths, but os_walk does not

Jim Schwartz report at bugs.python.org
Wed Dec 15 14:12:59 EST 2021


Jim Schwartz <jschwar at sbcglobal.net> added the comment:

when I run the following command:

python "H:\Users\LindaJim\Documents\AWS Python Learning\test_dir_scan_dir.py" "C:\\"

I get this output:

...
Traceback (most recent call last):
  File "H:\Users\LindaJim\Documents\AWS Python Learning\test_dir_scan_dir.py", line 54, in <module>
    main(sys.argv[0:])
  File "H:\Users\LindaJim\Documents\AWS Python Learning\test_dir_scan_dir.py", line 30, in main
    for file in get_files_in_dir(source):
  File "H:\Users\LindaJim\Documents\AWS Python Learning\test_dir_scan_dir.py", line 11, in get_files_in_dir
    yield from get_files_in_dir(entry.path)
  File "H:\Users\LindaJim\Documents\AWS Python Learning\test_dir_scan_dir.py", line 11, in get_files_in_dir
    yield from get_files_in_dir(entry.path)
  File "H:\Users\LindaJim\Documents\AWS Python Learning\test_dir_scan_dir.py", line 11, in get_files_in_dir
    yield from get_files_in_dir(entry.path)
  [Previous line repeated 19 more times]
  File "H:\Users\LindaJim\Documents\AWS Python Learning\test_dir_scan_dir.py", line 9, in get_files_in_dir
    for entry in os.scandir(source):
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\Jim\\Documents\\jschw_uiowtv3_old\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Extensions\\nenlahapcbofgnanklpelkaejcehkggg\\0.1.823.675_0\\notifications\\pages\\Cashback\\components\\CashBackResolve\\components\\RewardsActivation\\components\\CashbackSectionSimple'

when I run the following command:

python "H:\Users\LindaJim\Documents\AWS Python Learning\test_os_walk.py" "C:\\"

I get this:

...
file is  C:\winutils\bin\winutils.exe
End time is  2021-12-15.13:11:54
Duration is  0:06:05

I don't think this should happen, right?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46084>
_______________________________________


More information about the Python-bugs-list mailing list