[New-bugs-announce] [issue31716] os.path.isdir returns true for dots
Mor Haviv
report at bugs.python.org
Fri Oct 6 11:26:29 EDT 2017
New submission from Mor Haviv <morhaviv14 at gmail.com>:
I uploaded this as a question on Stack Overflow and I suspect it might be a bug. Here is the link for the Stack Overflow question: https://stackoverflow.com/questions/46608731/python-os-path-isdir-returns-true-for-dots/46608842#46608842
The problem itself (copied from what I uploaded on Stack Overflow):
I'm programming my own shell in python. Right now I'm trying to implement the `cd` command to my shell.
The function that performs this command has several variables:
`self.current_dir = "C:\\"` - The default value, it changes depends on the user's input using the cd command
`dir = "..."` - The requested directory that the user types. "..." is an example for an input that causes the problem.
Here is my code:
def command_cd(self, dir):
if os.path.isdir(self.shell.current_dir + dir):
self.shell.current_dir = self.shell.current_dir + dir + "\\"
The problem is that for some strange reason, `os.path.isdir(self.shell.current_dir + dir)` returns `True` when the user types dots (Just like the example inputs for the variables which I gave above).
The problem occurs even if you change the amount of dots (even above 5 dots) and I really have no idea what causes it.
There's obviously no folder named `...` or anything like it.
**If my problem isn't clear enough please comment and I'll edit it**
----------
components: Windows
messages: 303827
nosy: morha13, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: os.path.isdir returns true for dots
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31716>
_______________________________________
More information about the New-bugs-announce
mailing list