Skip to content

Commit

Permalink
fixup! bpo-1154351: add get_current_dir_name() to os module
Browse files Browse the repository at this point in the history
  • Loading branch information
bradengroom committed Oct 27, 2018
1 parent d49fdf3 commit 17386e1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1702,10 +1702,10 @@ features:
.. function:: get_current_dir_name()

Return a string representing the current working directory taking into
consideration the users ``PWD`` environment variable if it exists. This is
opposed to :func:`getcwd()` which dereferences symlinks in the path. This
function is identical to :func:`getcwd()` on systems that do **not**
support the ``PWD`` environment variable.
consideration the users :envvar:`PWD` environment variable if it exists. This is
opposed to :func:`getcwd` which dereferences symlinks in the path. This
function is identical to :func:`getcwd` on systems that do **not**
support the :envvar:`PWD` environment variable.

.. versionadded:: 3.8

Expand Down
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ by right-clicking the button. (Contributed by Tal Einat in :issue:`1529353`.)
The changes above have been backported to 3.7 maintenance releases.


os
--

Added :func:`~os.get_current_dir_name` function.
(Contributed by Braden Groom in :issue:`1154351`.)

os.path
-------

Expand Down
3 changes: 0 additions & 3 deletions Lib/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,15 +660,12 @@ def get_current_dir_name():
the *PWD* environment variable.
"""
cwd = getcwd()

if name == 'nt':
return cwd

try:
pwd = environ["PWD"]
except KeyError:
return cwd

if path.samefile(cwd, pwd):
return pwd
return cwd
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Add get_current_dir_name() to the os module.
Patch by Braden Groom

0 comments on commit 17386e1

Please sign in to comment.