WIP: bpo-36021: WindowsDefault does not execute os.startfile() for a local file by matrixise · Pull Request #11931 · python/cpython

@matrixise

@matrixise

@matrixise matrixise changed the title bpo-36021: WindowsDefault does not execute os.startfile() for a local file WIP: bpo-36021: WindowsDefault does not execute os.startfile() for a local file

Feb 19, 2019

@matrixise

@matrixise

@JulienPalard

Have you tried to implement three cases instead of two:

  • file://
  • whitelisted schemes
  • other cases

It may make the intention more readable, by removing - set(['file', '']) and if parsed_url.scheme == 'file'.

?

Also I'm not sure about the behavior of os.access(path, os.X_OK) in windows. Do os.startfile executes a .exe file that is not marked X_OK? (Not a Windows user here).

@matrixise

@matrixise

@JulienPalard
file:// is already tested with file:///tmp/test.txt
for the whitelisted schemes, you have an example with https://

about os.access(path, os.X_OK), after a small check on a Windows VM, it's not portable :/ I use an other solution in my last commit (I read the binary file and read the two first bytes == b'MZ')

@matrixise

@matrixise

ok, I have a whitelist and I allow the HTML files with WebBrowser.WindowsDefault()

vstinner

Choose a reason for hiding this comment

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

@bedevere-bot

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@JulienPalard

@matrixise

@JulienPalard yep, still WIP because we have a discussion about the solution on the bug tracker.

@matrixise