-
-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in convert_os_errors #484
Comments
PR: #491 |
@lurch So I would do this to test:
should be resource locked error but I just found I get this:
https://github.com/PyFilesystem/pyfilesystem2/blob/master/fs/error_tools.py#L63 this line prevents the correct error raising since it remaps FILE_ERRORS[13] and errno.EACCES is 13 so |
@isaacHuh I meant a way to provoke this from actual pyfilesystem code, not provoking it by manually constructing an "artificial OSError" that we may or may not ever actually see in the real world 😉 |
haven't gotten this working but something like this and you could try creating another process that interacts with the file while there is a lock on it. Or you could use an application like storyline 360 that holds a lock on a file to test and have that file open while you run a script that attempts to write to it. Both should work but haven't tried it myself. idk if thats what you were looking for |
Yes, that's more along the lines of what I meant with "do you have a reliable way of triggering this exception?" 👍
Ahh, that's a shame. As I suggested in #491 "I guess there's a possibility that this code may not even be needed now, given the changes to both Windows and Python over the past 12 years?" 🤷♂️ 🤷♂️ |
@lurch oh ok I see. This code does get hit when a process is attempting to read or write to a file that another process has a lock on it tho. I've seen storyline 360 causing this to get hit because that application holds a lock on a file the entire time it has the file open while most other applications don't, so any other process attempting to read from the file throws would throw a resource locked error. I played with it a bit after work and this raises the exception. just run file 1 and run file 2 while file 1 is sleep. Again I get fs.errors.FileExpected when it should be resource locked when I run this because of the bug but this is it: file 1:
file 2:
|
ok this works too:
|
Fantastic, thanks! 👍 ping @dargueta |
I don't have access to a Windows machine to test this, but could you change with convert_os_errors("test", sys_path):
os.write(fd, new_content) to import pprint
try:
with convert_os_errors("test", sys_path):
os.write(fd, new_content)
except Exception as err:
pprint.pprint(vars(err))
raise and see what that spits out? It won't fix anything, it'll just give me a bit more to work with. |
@dargueta yeah I'll take a look. Here's the previous output from before:
I didn't see your previous message before |
pyfilesystem2/fs/error_tools.py
Line 87 in 2d0ffc3
This compares a tuple to int and is always false.
The text was updated successfully, but these errors were encountered: