Message391119
In ntpath._getfinalpathname_nonstrict(), `tail` should be initialized to `path[:0]`.
Currently `tail` is initialized to the empty string value ''. If an error occurs that's allowed and `path` is a root directory that's passed as bytes, then joining `path + tail` will fail if `tail` still has its initial value.
To reproduce this issue, create a substitute drive for a directory that grants no access. For example:
import os
os.mkdir('spam')
os.system('icacls spam /inheritance:r')
os.system('subst N: spam')
>>> os.path.realpath(b'N:/')
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\ntpath.py", line 647, in realpath
path = _getfinalpathname(path)
PermissionError: [WinError 5] Access is denied: b'N:\\'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\ntpath.py", line 601, in _getfinalpathname_nonstrict
path = _getfinalpathname(path)
PermissionError: [WinError 5] Access is denied: b'N:\\'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python39\lib\ntpath.py", line 651, in realpath
path = _getfinalpathname_nonstrict(path)
File "C:\Program Files\Python39\lib\ntpath.py", line 621, in _getfinalpathname_nonstrict
return path + tail
TypeError: can't concat str to bytes |
|
Date |
User |
Action |
Args |
2021-04-15 07:15:50 | eryksun | set | recipients:
+ eryksun, paul.moore, tim.golden, Antoine d'Otreppe, zach.ware, steve.dower |
2021-04-15 07:15:50 | eryksun | set | messageid: <1618470950.91.0.73100161618.issue43847@roundup.psfhosted.org> |
2021-04-15 07:15:50 | eryksun | link | issue43847 messages |
2021-04-15 07:15:50 | eryksun | create | |
|