Skip to content
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

[input]Fix FileNotFoundError when sys path doesn't exist #5535

Merged
merged 1 commit into from
Dec 30, 2017
Merged

[input]Fix FileNotFoundError when sys path doesn't exist #5535

merged 1 commit into from
Dec 30, 2017

Conversation

thecodenomad
Copy link
Contributor

This is intended to fix #5534

You get a FileNotFoundError when trying to access '/sys/class/input/event/device/capabilities/abs' when the full path doesn't exist.

This may be an input device, but capabilities aren't listed so the fix just defaults "0".

@welcome
Copy link

welcome bot commented Dec 13, 2017

Thanks for opening your first pull request here! 💖 Please check out our contributing guidelines.

@KeyWeeUsr
Copy link
Contributor

Ref e18cd35#diff-2eeaed663bd0d25b7e608891384b7298 try to use OSError instead.

Also, shouldn't you instead just return [] from the exception? What's the point of going through the computation and return [False]?

@thecodenomad
Copy link
Contributor Author

thecodenomad commented Dec 30, 2017

All good points ;) Updated the fix based on comments (squashed commits as well, sorry about that).

Fixed whitespace

Updated based on comments from PR
@tito
Copy link
Member

tito commented Dec 30, 2017

Thanks you!

@tito tito merged commit 0db3b02 into kivy:master Dec 30, 2017
@welcome
Copy link

welcome bot commented Dec 30, 2017

Congrats on merging your first pull request! 🎉🎉🎉

line = "0"
try:
line = read_line(path)
except OSError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not throwing a IOError (python2) or FileNotFoundError (python3) instead?

Copy link
Contributor

@KeyWeeUsr KeyWeeUsr Nov 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it returns OSError for Windows, but I'm not sure if OSError is the parent or IOError, sooo... test or check with cpython source I'd say :) It should handle FNF in either case for py3 iirc.

Edit: I'd add it, so that it's a tuple with IO and OS errors caught.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Yes at the same time I'm getting confused by other commits d80528b which seems to tackle it, but I didn't investigate why I don't see it in the code base.
In the meantime, this is what I have on Linux (python2 and python3):

[andre:/tmp] 2 $ python2 -c "open('/does_not_exist/')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
IOError: [Errno 2] No such file or directory: '/does_not_exist/'
[andre:/tmp] 1 $ python3 -c "open('/does_not_exist/')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/does_not_exist/'
[andre:/tmp] 1 $ 

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndreMiras This resolves FNF → https://github.com/python/cpython/blob/621cebe81b1e6c8de10425955bf532d31ee4df42/Objects/exceptions.c#L1256 (OSError), for the rest just append IOError if it still brags :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh didn't know about that thingy. Thanks

@matham matham changed the title Fix FileNotFoundError when sys path doesn't exist [input]Fix FileNotFoundError when sys path doesn't exist May 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileNotFoundError when input/event doesn't present device/capabilities/abs
4 participants