msg282241 - (view) |
Author: Christoph Reiter (lazka) * |
Date: 2016-12-02 14:39 |
It returns True for drives which don't exist and raises for paths starting with drives which don't exist. >>> os.path.exists("C:\\") True >>> os.path.ismount("C:\\") True >>> os.path.ismount("C:\\doesnotexist") False >>> os.path.exists("F:\\") False >>> os.path.ismount("F:\\") True >>> os.path.ismount("F:\\doesnotexist") Traceback (most recent call last): File "", line 1, in File "C:\Users\lazka\AppData\Local\Programs\Python\Python35\lib\ntpath.py", line 290, in ismount return path.rstrip(seps) == _getvolumepathname(path).rstrip(seps) FileNotFoundError: [WinError 2] The system cannot find the file specified: 'F:\\doesnotexist' |
|
|
msg357723 - (view) |
Author: Steve Dower (steve.dower) *  |
Date: 2019-12-02 17:52 |
Traditionally we handle exceptions in os.path.is* functions and return False. |
|
|
msg361634 - (view) |
Author: Nishant Misra (scic0) |
Date: 2020-02-08 15:34 |
I would like to take this issue as my first issue to start contributing to Python development. |
|
|
msg362039 - (view) |
Author: szb512 (sdcards) |
Date: 2020-02-16 00:31 |
I am going to think maybe it was the "os.path.ismount" command that is causing the issue. Does the file exist? |
|
|
msg362238 - (view) |
Author: Steve Dower (steve.dower) *  |
Date: 2020-02-18 23:05 |
> I am going to think maybe it was the "os.path.ismount" command that is causing the issue. Does the file exist? If the file does not exist, it is definitely not a mount point. So the function should return False instead of raising an error. |
|
|
msg364476 - (view) |
Author: Lahfa Samy (AkechiShiro) * |
Date: 2020-03-17 20:22 |
Nishant Misra are you still working on this issue, if not could I take it from now on, as my first issue and contribution to Python? |
|
|
msg364486 - (view) |
Author: Nishant Misra (scic0) |
Date: 2020-03-17 22:20 |
Yes Lahfa Samy, you can take it up. I did not work on the issue. |
|
|
msg365132 - (view) |
Author: Zhu Sheng Li (akarei) * |
Date: 2020-03-27 02:58 |
I submitted a PR and get reviewed by @lazka. Is there anything I should do for pushing it to next step? |
|
|
msg365196 - (view) |
Author: Steve Dower (steve.dower) *  |
Date: 2020-03-27 23:56 |
Reminding us on here is helpful (for me, anyway). I just left a couple of suggestions to make sure we handle all the cases. It's important when you change or add tests that you make sure the test fails without your fix - otherwise it might not be testing the fix! |
|
|
msg365591 - (view) |
Author: Ankesh Saha (ankeshsaha) * |
Date: 2020-04-02 13:07 |
s I have tried to workout a solution for the problem. Below is my observation and possible solution. os.path.ismount("F:\\doesnotexist") Exception occurs for the above line if the system fails to find both drive and the path that follows it. A 'FileNotFoundError' exception is thrown. If we can handle this exception and return false for method ismount(), then problem can be resolved. I changed the existing code ismount method and it is working. Existing code=> if _getvolumepathname: return path.rstrip(seps) == _getvolumepathname(path).rstrip(seps) else: return False Changed Code=> if _getvolumepathname: try: return path.rstrip(seps) == _getvolumepathname(path).rstrip(seps) except FileNotFoundError: return False Please check, if this solution is correct. |
|
|
msg369747 - (view) |
Author: Cheryl Sabella (cheryl.sabella) *  |
Date: 2020-05-23 20:05 |
@steve.dower, please review the changes when you get a chance. Thanks! |
|
|