From 1c24cd61772142edd54475cba80d1637557c05ca 2016-12-27 02:25:34
From: Srinivas Reddy Thatiparthy <thatiparthysreenivas@gmail.com>
Date: 2016-12-27 02:25:34
Subject: [PATCH] rename py3compat.getcwd() -> os.getcwd()

---

diff --git a/IPython/core/application.py b/IPython/core/application.py
index 1801627..d6ad998 100644
--- a/IPython/core/application.py
+++ b/IPython/core/application.py
@@ -126,7 +126,7 @@ class BaseIPythonApplication(Application):
     config_file_paths = List(Unicode())
     @default('config_file_paths')
     def _config_file_paths_default(self):
-        return [py3compat.getcwd()]
+        return [os.getcwd()]
 
     extra_config_file = Unicode(
     help="""Path to an extra config file to load.
@@ -215,7 +215,7 @@ class BaseIPythonApplication(Application):
         super(BaseIPythonApplication, self).__init__(**kwargs)
         # ensure current working directory exists
         try:
-            py3compat.getcwd()
+            os.getcwd()
         except:
             # exit if cwd doesn't exist
             self.log.error("Current working directory doesn't exist.")
diff --git a/IPython/core/history.py b/IPython/core/history.py
index 58d20ec..16efbcd 100644
--- a/IPython/core/history.py
+++ b/IPython/core/history.py
@@ -487,7 +487,7 @@ class HistoryManager(HistoryAccessor):
     @default('dir_hist')
     def _dir_hist_default(self):
         try:
-            return [py3compat.getcwd()]
+            return [os.getcwd()]
         except OSError:
             return []
 
@@ -593,7 +593,7 @@ class HistoryManager(HistoryAccessor):
         optionally open a new session."""
         self.output_hist.clear()
         # The directory history can't be completely empty
-        self.dir_hist[:] = [py3compat.getcwd()]
+        self.dir_hist[:] = [os.getcwd()]
         
         if new_session:
             if self.session_number:
diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
index c892c22..970ef65 100644
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -549,7 +549,7 @@ class InteractiveShell(SingletonConfigurable):
 
         # keep track of where we started running (mainly for crash post-mortem)
         # This is not being used anywhere currently.
-        self.starting_dir = py3compat.getcwd()
+        self.starting_dir = os.getcwd()
 
         # Indentation management
         self.indent_current_nsp = 0
diff --git a/IPython/core/magics/osm.py b/IPython/core/magics/osm.py
index a301ee4..e1fbbad 100644
--- a/IPython/core/magics/osm.py
+++ b/IPython/core/magics/osm.py
@@ -177,7 +177,7 @@ class OSMagics(Magics):
                 winext += '|py'
             execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
             isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
-        savedir = py3compat.getcwd()
+        savedir = os.getcwd()
 
         # Now walk the paths looking for executables to alias.
         try:
@@ -239,7 +239,7 @@ class OSMagics(Magics):
           In [9]: pwd
           Out[9]: '/home/tsuser/sprint/ipython'
         """
-        return py3compat.getcwd()
+        return os.getcwd()
 
     @skip_doctest
     @line_magic
@@ -283,7 +283,7 @@ class OSMagics(Magics):
           /home/tsuser/parent/child
         """
 
-        oldcwd = py3compat.getcwd()
+        oldcwd = os.getcwd()
         numcd = re.match(r'(-)(\d+)$',parameter_s)
         # jump in directory history by number
         if numcd:
@@ -351,7 +351,7 @@ class OSMagics(Magics):
             except OSError:
                 print(sys.exc_info()[1])
             else:
-                cwd = py3compat.getcwd()
+                cwd = os.getcwd()
                 dhist = self.shell.user_ns['_dh']
                 if oldcwd != cwd:
                     dhist.append(cwd)
@@ -361,7 +361,7 @@ class OSMagics(Magics):
             os.chdir(self.shell.home_dir)
             if hasattr(self.shell, 'term_title') and self.shell.term_title:
                 set_term_title('IPython: ' + '~')
-            cwd = py3compat.getcwd()
+            cwd = os.getcwd()
             dhist = self.shell.user_ns['_dh']
 
             if oldcwd != cwd:
@@ -436,7 +436,7 @@ class OSMagics(Magics):
 
         dir_s = self.shell.dir_stack
         tgt = os.path.expanduser(parameter_s)
-        cwd = py3compat.getcwd().replace(self.shell.home_dir,'~')
+        cwd = os.getcwd().replace(self.shell.home_dir,'~')
         if tgt:
             self.cd(parameter_s)
         dir_s.insert(0,cwd)
@@ -724,7 +724,7 @@ class OSMagics(Magics):
             if not args:
                 raise UsageError("%bookmark: You must specify the bookmark name")
             elif len(args)==1:
-                bkms[args[0]] = py3compat.getcwd()
+                bkms[args[0]] = os.getcwd()
             elif len(args)==2:
                 bkms[args[0]] = args[1]
         self.shell.db['bookmarks'] = bkms
diff --git a/IPython/core/profileapp.py b/IPython/core/profileapp.py
index ee78ab6..f43962f 100644
--- a/IPython/core/profileapp.py
+++ b/IPython/core/profileapp.py
@@ -180,10 +180,10 @@ class ProfileList(Application):
             print("Available profiles in %s:" % self.ipython_dir)
             self._print_profiles(profiles)
         
-        profiles = list_profiles_in(py3compat.getcwd())
+        profiles = list_profiles_in(os.getcwd())
         if profiles:
             print()
-            print("Available profiles in current directory (%s):" % py3compat.getcwd())
+            print("Available profiles in current directory (%s):" % os.getcwd())
             self._print_profiles(profiles)
         
         print()
diff --git a/IPython/core/profiledir.py b/IPython/core/profiledir.py
index 9c9e99c..6c0dc7b 100644
--- a/IPython/core/profiledir.py
+++ b/IPython/core/profiledir.py
@@ -187,7 +187,7 @@ class ProfileDir(LoggingConfigurable):
         is not found, a :class:`ProfileDirError` exception will be raised.
 
         The search path algorithm is:
-        1. ``py3compat.getcwd()``
+        1. ``os.getcwd()``
         2. ``ipython_dir``
 
         Parameters
@@ -199,7 +199,7 @@ class ProfileDir(LoggingConfigurable):
             will be "profile_<profile>".
         """
         dirname = u'profile_' + name
-        paths = [py3compat.getcwd(), ipython_dir]
+        paths = [os.getcwd(), ipython_dir]
         for p in paths:
             profile_dir = os.path.join(p, dirname)
             if os.path.isdir(profile_dir):
diff --git a/IPython/core/tests/test_application.py b/IPython/core/tests/test_application.py
index 0808712..34cab5b 100644
--- a/IPython/core/tests/test_application.py
+++ b/IPython/core/tests/test_application.py
@@ -19,9 +19,9 @@ def test_unicode_cwd():
     """Check that IPython starts with non-ascii characters in the path."""
     wd = tempfile.mkdtemp(suffix=u"€")
     
-    old_wd = py3compat.getcwd()
+    old_wd = os.getcwd()
     os.chdir(wd)
-    #raise Exception(repr(py3compat.getcwd()))
+    #raise Exception(repr(os.getcwd()))
     try:
         app = BaseIPythonApplication()
         # The lines below are copied from Application.initialize()
diff --git a/IPython/core/tests/test_completerlib.py b/IPython/core/tests/test_completerlib.py
index 0f10884..97b561d 100644
--- a/IPython/core/tests/test_completerlib.py
+++ b/IPython/core/tests/test_completerlib.py
@@ -41,7 +41,7 @@ class Test_magic_run_completer(unittest.TestCase):
         for d in self.dirs:
             os.mkdir(join(self.BASETESTDIR, d))
 
-        self.oldpath = py3compat.getcwd()
+        self.oldpath = os.getcwd()
         os.chdir(self.BASETESTDIR)
 
     def tearDown(self):
@@ -94,7 +94,7 @@ class Test_magic_run_completer_nonascii(unittest.TestCase):
         for fil in [u"aaø.py", u"a.py", u"b.py"]:
             with open(join(self.BASETESTDIR, fil), "w") as sfile:
                 sfile.write("pass\n")
-        self.oldpath = py3compat.getcwd()
+        self.oldpath = os.getcwd()
         os.chdir(self.BASETESTDIR)
 
     def tearDown(self):
diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py
index 65190aa..9236b7a 100644
--- a/IPython/core/tests/test_interactiveshell.py
+++ b/IPython/core/tests/test_interactiveshell.py
@@ -485,7 +485,7 @@ class TestSafeExecfileNonAsciiPath(unittest.TestCase):
         os.mkdir(self.TESTDIR)
         with open(join(self.TESTDIR, u"åäötestscript.py"), "w") as sfile:
             sfile.write("pass\n")
-        self.oldpath = py3compat.getcwd()
+        self.oldpath = os.getcwd()
         os.chdir(self.TESTDIR)
         self.fname = u"åäötestscript.py"
 
diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py
index 6fea789..71c9692 100644
--- a/IPython/core/tests/test_magic.py
+++ b/IPython/core/tests/test_magic.py
@@ -393,9 +393,9 @@ def test_parse_options():
     
 def test_dirops():
     """Test various directory handling operations."""
-    # curpath = lambda :os.path.splitdrive(py3compat.getcwd())[1].replace('\\','/')
-    curpath = py3compat.getcwd
-    startdir = py3compat.getcwd()
+    # curpath = lambda :os.path.splitdrive(os.getcwd())[1].replace('\\','/')
+    curpath = os.getcwd
+    startdir = os.getcwd()
     ipdir = os.path.realpath(_ip.ipython_dir)
     try:
         _ip.magic('cd "%s"' % ipdir)
diff --git a/IPython/core/tests/test_run.py b/IPython/core/tests/test_run.py
index f73d235..d684990 100644
--- a/IPython/core/tests/test_run.py
+++ b/IPython/core/tests/test_run.py
@@ -408,7 +408,7 @@ class TestMagicRunWithPackage(unittest.TestCase):
         self.value = int(random.random() * 10000)
 
         self.tempdir = TemporaryDirectory()
-        self.__orig_cwd = py3compat.getcwd()
+        self.__orig_cwd = os.getcwd()
         sys.path.insert(0, self.tempdir.name)
 
         self.writefile(os.path.join(package, '__init__.py'), '')
diff --git a/IPython/utils/_process_win32.py b/IPython/utils/_process_win32.py
index 554cf9f..bfad1b5 100644
--- a/IPython/utils/_process_win32.py
+++ b/IPython/utils/_process_win32.py
@@ -53,7 +53,7 @@ class AvoidUNCPath(object):
             os.system(cmd)
     """
     def __enter__(self):
-        self.path = py3compat.getcwd()
+        self.path = os.getcwd()
         self.is_unc_path = self.path.startswith(r"\\")
         if self.is_unc_path:
             # change to c drive (as cmd.exe cannot handle UNC addresses)
diff --git a/IPython/utils/_process_win32_controller.py b/IPython/utils/_process_win32_controller.py
index 85a342e..4fd2e3c 100644
--- a/IPython/utils/_process_win32_controller.py
+++ b/IPython/utils/_process_win32_controller.py
@@ -173,7 +173,7 @@ class AvoidUNCPath(object):
             os.system(cmd)
     """
     def __enter__(self):
-        self.path = py3compat.getcwd()
+        self.path = os.getcwd()
         self.is_unc_path = self.path.startswith(r"\\")
         if self.is_unc_path:
             # change to c drive (as cmd.exe cannot handle UNC addresses)
diff --git a/IPython/utils/path.py b/IPython/utils/path.py
index d54a709..8cabaad 100644
--- a/IPython/utils/path.py
+++ b/IPython/utils/path.py
@@ -158,7 +158,7 @@ def filefind(filename, path_dirs=None):
         path_dirs = (path_dirs,)
 
     for path in path_dirs:
-        if path == '.': path = py3compat.getcwd()
+        if path == '.': path = os.getcwd()
         testname = expand_path(os.path.join(path, filename))
         if os.path.isfile(testname):
             return os.path.abspath(testname)
diff --git a/IPython/utils/process.py b/IPython/utils/process.py
index 169d3c3..77b2064 100644
--- a/IPython/utils/process.py
+++ b/IPython/utils/process.py
@@ -52,7 +52,7 @@ def find_cmd(cmd):
 
 def abbrev_cwd():
     """ Return abbreviated version of cwd, e.g. d:mydir """
-    cwd = py3compat.getcwd().replace('\\','/')
+    cwd = os.getcwd().replace('\\','/')
     drivepart = ''
     tail = cwd
     if sys.platform == 'win32':
diff --git a/IPython/utils/terminal.py b/IPython/utils/terminal.py
index 3bdcee3..4668994 100644
--- a/IPython/utils/terminal.py
+++ b/IPython/utils/terminal.py
@@ -93,7 +93,7 @@ elif sys.platform == 'win32':
 
             try:
                 # Cannot be on network share when issuing system commands
-                curr = py3compat.getcwd()
+                curr = os.getcwd()
                 os.chdir("C:")
                 ret = os.system("title " + title)
             finally:
diff --git a/IPython/utils/tests/test_path.py b/IPython/utils/tests/test_path.py
index 4aba13f..95f677e 100644
--- a/IPython/utils/tests/test_path.py
+++ b/IPython/utils/tests/test_path.py
@@ -356,7 +356,7 @@ class TestShellGlob(object):
     @classmethod
     @contextmanager
     def in_tempdir(cls):
-        save = py3compat.getcwd()
+        save = os.getcwd()
         try:
             os.chdir(cls.tempdir.name)
             yield