diff --git a/IPython/core/crashhandler.py b/IPython/core/crashhandler.py index 9db465a..9804255 100644 --- a/IPython/core/crashhandler.py +++ b/IPython/core/crashhandler.py @@ -119,9 +119,9 @@ class CrashHandler(object): try: rptdir = self.app.ipython_dir except: - rptdir = os.getcwd() + rptdir = os.getcwdu() if rptdir is None or not os.path.isdir(rptdir): - rptdir = os.getcwd() + rptdir = os.getcwdu() report_name = os.path.join(rptdir,self.crash_report_fname) # write the report filename into the instance dict so it can get # properly expanded out in the user message template diff --git a/IPython/core/history.py b/IPython/core/history.py index 723b150..7064253 100644 --- a/IPython/core/history.py +++ b/IPython/core/history.py @@ -47,7 +47,7 @@ class HistoryManager(Configurable): dir_hist = List() def _dir_hist_default(self): try: - return [os.getcwd()] + return [os.getcwdu()] except OSError: return [] @@ -173,7 +173,7 @@ class HistoryManager(Configurable): optionally open a new session.""" self.output_hist.clear() # The directory history can't be completely empty - self.dir_hist[:] = [os.getcwd()] + self.dir_hist[:] = [os.getcwdu()] if new_session: if self.session_number: diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 7ccdf97..fa444a7 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -500,7 +500,7 @@ class InteractiveShell(SingletonConfigurable, Magic): # keep track of where we started running (mainly for crash post-mortem) # This is not being used anywhere currently. - self.starting_dir = os.getcwd() + self.starting_dir = os.getcwdu() # Indentation management self.indent_current_nsp = 0 diff --git a/IPython/core/magic.py b/IPython/core/magic.py index bfb3c3b..51704c5 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -2673,7 +2673,7 @@ Defaulting color scheme to 'NoColor'""" winext += '|py' execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE) isexec = lambda fname:os.path.isfile(fname) and execre.match(fname) - savedir = os.getcwd() + savedir = os.getcwdu() # Now walk the paths looking for executables to alias. try: @@ -2726,7 +2726,7 @@ Defaulting color scheme to 'NoColor'""" In [9]: pwd Out[9]: '/home/tsuser/sprint/ipython' """ - return os.getcwd() + return os.getcwdu() @skip_doctest def magic_cd(self, parameter_s=''): @@ -2772,7 +2772,7 @@ Defaulting color scheme to 'NoColor'""" parameter_s = parameter_s.strip() #bkms = self.shell.persist.get("bookmarks",{}) - oldcwd = os.getcwd() + oldcwd = os.getcwdu() numcd = re.match(r'(-)(\d+)$',parameter_s) # jump in directory history by number if numcd: @@ -2846,7 +2846,7 @@ Defaulting color scheme to 'NoColor'""" except OSError: print sys.exc_info()[1] else: - cwd = os.getcwd() + cwd = os.getcwdu() dhist = self.shell.user_ns['_dh'] if oldcwd != cwd: dhist.append(cwd) @@ -2856,7 +2856,7 @@ Defaulting color scheme to 'NoColor'""" os.chdir(self.shell.home_dir) if hasattr(self.shell, 'term_title') and self.shell.term_title: set_term_title('IPython: ' + '~') - cwd = os.getcwd() + cwd = os.getcwdu() dhist = self.shell.user_ns['_dh'] if oldcwd != cwd: @@ -2880,7 +2880,7 @@ Defaulting color scheme to 'NoColor'""" dir_s = self.shell.dir_stack tgt = os.path.expanduser(parameter_s) - cwd = os.getcwd().replace(self.home_dir,'~') + cwd = os.getcwdu().replace(self.home_dir,'~') if tgt: self.magic_cd(parameter_s) dir_s.insert(0,cwd) @@ -3145,7 +3145,7 @@ Defaulting color scheme to 'NoColor'""" if not args: raise UsageError("%bookmark: You must specify the bookmark name") elif len(args)==1: - bkms[args[0]] = os.getcwd() + bkms[args[0]] = os.getcwdu() elif len(args)==2: bkms[args[0]] = args[1] self.db['bookmarks'] = bkms diff --git a/IPython/core/profiledir.py b/IPython/core/profiledir.py index 5f7615f..2051d75 100644 --- a/IPython/core/profiledir.py +++ b/IPython/core/profiledir.py @@ -167,7 +167,7 @@ class ProfileDir(Configurable): is not found, a :class:`ProfileDirError` exception will be raised. The search path algorithm is: - 1. ``os.getcwd()`` + 1. ``os.getcwdu()`` 2. ``ipython_dir`` Parameters diff --git a/IPython/core/prompts.py b/IPython/core/prompts.py index 2964320..e08c249 100644 --- a/IPython/core/prompts.py +++ b/IPython/core/prompts.py @@ -224,9 +224,9 @@ def str_safe(arg): except Exception,msg: # let's keep this little duplication here, so that the most common # case doesn't suffer from a double try wrapping. - out = '' % msg + out = '' % msg except Exception,msg: - out = '' % msg + out = '' % msg #raise # dbg return out diff --git a/IPython/core/tests/test_application.py b/IPython/core/tests/test_application.py index 8183fc9..3a59a0f 100644 --- a/IPython/core/tests/test_application.py +++ b/IPython/core/tests/test_application.py @@ -14,7 +14,7 @@ def test_unicode_cwd(): old_wd = os.getcwdu() os.chdir(wd) - #raise Exception(repr(os.getcwd())) + #raise Exception(repr(os.getcwdu())) try: app = BaseIPythonApplication() # The lines below are copied from Application.initialize() diff --git a/IPython/external/Itpl/_Itpl.py b/IPython/external/Itpl/_Itpl.py index 671e9ab..bd69235 100644 --- a/IPython/external/Itpl/_Itpl.py +++ b/IPython/external/Itpl/_Itpl.py @@ -196,7 +196,7 @@ class Itpl: for live, chunk in self.chunks: if live: app(str(eval(chunk,glob,loc))) else: app(chunk) - out = ''.join(result) + out = u''.join(result) try: return str(out) except UnicodeError: @@ -212,6 +212,9 @@ class Itpl: loc, glob = frame.f_locals, frame.f_globals return self._str(glob,loc) + + def encode(self, encoding, errors): + return str(self)#.encode(encoding, errors) class ItplNS(Itpl): """Class representing a string with interpolation abilities. diff --git a/IPython/external/path/_path.py b/IPython/external/path/_path.py index 4abe32d..e7e2e19 100644 --- a/IPython/external/path/_path.py +++ b/IPython/external/path/_path.py @@ -245,7 +245,7 @@ class path(unicode): """ Return this path as a relative path, based from the current working directory. """ - cwd = self.__class__(os.getcwd()) + cwd = self.__class__(os.getcwdu()) return cwd.relpathto(self) def relpathto(self, dest): diff --git a/IPython/quarantine/ipy_rehashdir.py b/IPython/quarantine/ipy_rehashdir.py index 7250470..07faf13 100644 --- a/IPython/quarantine/ipy_rehashdir.py +++ b/IPython/quarantine/ipy_rehashdir.py @@ -104,7 +104,7 @@ def rehashdir_f(self,arg): execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE) isexec = lambda fname:os.path.isfile(fname) and execre.match(fname) - savedir = os.getcwd() + savedir = os.getcwdu() try: # write the whole loop for posix/Windows so we don't have an if in # the innermost part diff --git a/IPython/quarantine/ipy_synchronize_with.py b/IPython/quarantine/ipy_synchronize_with.py index 51fe1f5..eed130e 100644 --- a/IPython/quarantine/ipy_synchronize_with.py +++ b/IPython/quarantine/ipy_synchronize_with.py @@ -37,7 +37,7 @@ def find_filename(filename): filename = "".join(filename) if not os.path.isabs(filename): - filename = os.path.join(os.getcwd(), filename) + filename = os.path.join(os.getcwdu(), filename) if os.path.isfile(filename): return filename diff --git a/IPython/quarantine/ipy_workdir.py b/IPython/quarantine/ipy_workdir.py index 53d9105..620fddc 100644 --- a/IPython/quarantine/ipy_workdir.py +++ b/IPython/quarantine/ipy_workdir.py @@ -33,7 +33,7 @@ def workdir_f(ip,line): if os.path.isfile(head): cmd = os.path.abspath(head) + ' ' + tail print "Execute command '" + cmd+ "' in",workdir - olddir = os.getcwd() + olddir = os.getcwdu() os.chdir(workdir) try: os.system(cmd) diff --git a/IPython/quarantine/jobctrl.py b/IPython/quarantine/jobctrl.py index 7518a52..0c8d70f 100644 --- a/IPython/quarantine/jobctrl.py +++ b/IPython/quarantine/jobctrl.py @@ -92,7 +92,7 @@ class AsyncJobQ(threading.Thread): self.output.append(out) def add(self,cmd): - self.q.put_nowait((cmd, os.getcwd())) + self.q.put_nowait((cmd, os.getcwdu())) def dumpoutput(self): while self.output: @@ -220,7 +220,7 @@ def jobctrl_shellcmd(ip,cmd): p = Popen(cmd,shell = True) jobentry = 'tasks/t' + str(p.pid) - ip.db[jobentry] = (p.pid,cmd,os.getcwd(),time.time()) + ip.db[jobentry] = (p.pid,cmd,os.getcwdu(),time.time()) p.communicate() finally: diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index b547a32..12149c8 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -385,7 +385,7 @@ def run_iptestall(): # to clean up any junk files left over by accident. This also makes it # robust against being run in non-writeable directories by mistake, as the # temp dir will always be user-writeable. - curdir = os.getcwd() + curdir = os.getcwdu() testdir = tempfile.gettempdir() os.chdir(testdir) diff --git a/IPython/testing/plugin/ipdoctest.py b/IPython/testing/plugin/ipdoctest.py index f2b2c75..1199657 100644 --- a/IPython/testing/plugin/ipdoctest.py +++ b/IPython/testing/plugin/ipdoctest.py @@ -250,7 +250,7 @@ class DocTestCase(doctests.DocTestCase): # Save our current directory and switch out to the one where the # test was originally created, in case another doctest did a # directory change. We'll restore this in the finally clause. - curdir = os.getcwd() + curdir = os.getcwdu() #print 'runTest in dir:', self._ori_dir # dbg os.chdir(self._ori_dir) diff --git a/IPython/utils/_process_win32.py b/IPython/utils/_process_win32.py index 094cc9b..3a273c0 100644 --- a/IPython/utils/_process_win32.py +++ b/IPython/utils/_process_win32.py @@ -49,7 +49,7 @@ class AvoidUNCPath(object): os.system(cmd) """ def __enter__(self): - self.path = os.getcwd() + self.path = os.getcwdu() 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.py b/IPython/utils/process.py index 2017395..2ed580b 100644 --- a/IPython/utils/process.py +++ b/IPython/utils/process.py @@ -129,7 +129,7 @@ def arg_split(s, posix=False): def abbrev_cwd(): """ Return abbreviated version of cwd, e.g. d:mydir """ - cwd = os.getcwd().replace('\\','/') + cwd = os.getcwdu().replace('\\','/') drivepart = '' tail = cwd if sys.platform == 'win32': diff --git a/IPython/utils/terminal.py b/IPython/utils/terminal.py index 062f532..a25a481 100644 --- a/IPython/utils/terminal.py +++ b/IPython/utils/terminal.py @@ -102,7 +102,7 @@ if sys.platform == 'win32': try: # Cannot be on network share when issuing system commands - curr = os.getcwd() + curr = os.getcwdu() os.chdir("C:") ret = os.system("title " + title) finally: diff --git a/docs/do_sphinx.py b/docs/do_sphinx.py index 02b2fba..23fe9eb 100755 --- a/docs/do_sphinx.py +++ b/docs/do_sphinx.py @@ -15,7 +15,7 @@ if sys.platform != 'win32': oscmd('sphinx-build -b latex -d build/doctrees source build/latex') # Produce pdf. - topdir = os.getcwd() + topdir = os.getcwdu() os.chdir('build/latex') # Change chapter style to section style: allows chapters to start on diff --git a/docs/examples/newparallel/davinci/pwordfreq.py b/docs/examples/newparallel/davinci/pwordfreq.py index 439cc16..77201a1 100644 --- a/docs/examples/newparallel/davinci/pwordfreq.py +++ b/docs/examples/newparallel/davinci/pwordfreq.py @@ -69,7 +69,7 @@ if __name__ == '__main__': with open('davinci%i.txt'%i, 'w') as f: f.write('\n'.join(chunk)) - cwd = os.path.abspath(os.getcwd()) + cwd = os.path.abspath(os.getcwdu()) fnames = [ os.path.join(cwd, 'davinci%i.txt'%i) for i in range(n)] tic = time.time() pfreqs = pwordfreq(view,fnames) diff --git a/docs/gh-pages.py b/docs/gh-pages.py index 0050841..dd360f8 100755 --- a/docs/gh-pages.py +++ b/docs/gh-pages.py @@ -69,7 +69,7 @@ def sh3(cmd): def init_repo(path): """clone the gh-pages repo if we haven't already.""" sh("git clone %s %s"%(pages_repo, path)) - here = os.getcwd() + here = os.getcwdu() cd(path) sh('git checkout gh-pages') cd(here) @@ -87,7 +87,7 @@ if __name__ == '__main__': except CalledProcessError: tag = "dev" # Fallback - startdir = os.getcwd() + startdir = os.getcwdu() if not os.path.exists(pages_dir): # init the repo init_repo(pages_dir) diff --git a/tools/gitwash_dumper.py b/tools/gitwash_dumper.py index 000245a..a44c5f9 100755 --- a/tools/gitwash_dumper.py +++ b/tools/gitwash_dumper.py @@ -16,7 +16,7 @@ verbose = False def clone_repo(url, branch): - cwd = os.getcwd() + cwd = os.getcwdu() tmpdir = tempfile.mkdtemp() try: cmd = 'git clone %s %s' % (url, tmpdir) diff --git a/tools/make_tarball.py b/tools/make_tarball.py index 11738be..33c5ec5 100755 --- a/tools/make_tarball.py +++ b/tools/make_tarball.py @@ -18,7 +18,7 @@ tar_name = '%s.tgz' % base_name # to the top of the tree. There are long threads (since 2007) on the git list # about this and it still doesn't work in a sensible way... -start_dir = os.getcwd() +start_dir = os.getcwdu() cd('..') git_tpl = 'git archive --format=tar --prefix={0}/ HEAD | gzip > {1}' sh(git_tpl.format(base_name, tar_name))