-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
bpo-1154351: Add get_current_dir_name() to os module #10117
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1daae93
bpo-1154351: add get_current_dir_name() to os module
bradengroom ee4c4f6
fixup! bpo-1154351: add get_current_dir_name() to os module
bradengroom f836691
fixup! bpo-1154351: add get_current_dir_name() to os module
bradengroom 89e1984
fixup! bpo-1154351: add get_current_dir_name() to os module
bradengroom 4bfb33c
fixup! bpo-1154351: add get_current_dir_name() to os module
bradengroom 963659a
fixup! bpo-1154351: add get_current_dir_name() to os module
bradengroom cc1735f
fixup! bpo-1154351: add get_current_dir_name() to os module
bradengroom d49fdf3
fixup! bpo-1154351: add get_current_dir_name() to os module
bradengroom 17386e1
fixup! bpo-1154351: add get_current_dir_name() to os module
bradengroom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
fixup! bpo-1154351: add get_current_dir_name() to os module
- Loading branch information
commit 17386e1b4dbbbb62a1a4189a291b40fb800e5edc
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -660,15 +660,12 @@ def get_current_dir_name(): | |
| the *PWD* environment variable. | ||
| """ | ||
| cwd = getcwd() | ||
|
|
||
| if name == 'nt': | ||
| return cwd | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added this so that we don't look at the |
||
|
|
||
| try: | ||
| pwd = environ["PWD"] | ||
| except KeyError: | ||
| return cwd | ||
|
|
||
| if path.samefile(cwd, pwd): | ||
| return pwd | ||
| return cwd | ||
|
|
||
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Library/2018-10-25-19-44-42.bpo-1154351.KhXLos.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| Add get_current_dir_name() to the os module. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Patch by ..." |
||
| Patch by Braden Groom | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you were performing review as I was writing a comment :)
#10117 (comment)
This function is documented with:
Please correct me if I'm wrong since I'm less familiar with Windows, but I don't believe it uses the
PWDenvironment variable in any way. I added that check so that we would not incorrectly change behavior fromgetcwd()if the user does set thePWDon Windows for some reason.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in
git bashon windows:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asottile
Thanks. Looks like my memory was incorrect. I'll fix this up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually not sure this function is useful/a good idea -- it's entirely dependent on whether
pythonis executed in the context of an interactive shell that sets or doesn't setPWD.I've commented on the bpo issue indicating that as well.