Merge pull request #4469 from takluyver/py3-getcwdu

Python 3 & getcwdu

We were using the os.getcwdu() function in several places. That doesn't exist on Python 3, but the path.py module was masking that by setting os.getcwdu = os.getcwd. As described in #4462, however, that didn't always work.

This adds a reference in py3compat which points to getcwd on Python 3 and getcwdu in Python 2.
This commit is contained in:
Min RK 2013-11-01 12:50:09 -07:00
commit 72611e43f2
2 changed files with 5 additions and 5 deletions

View File

@ -16,8 +16,6 @@ Authors:
# Imports
#-----------------------------------------------------------------------------
import os
from tornado import web
from zmq.eventloop import ioloop
@ -26,6 +24,7 @@ from IPython.utils.traitlets import Dict, Instance, CFloat
from IPython.parallel.apps.ipclusterapp import IPClusterStart
from IPython.core.profileapp import list_profiles_in
from IPython.core.profiledir import ProfileDir
from IPython.utils import py3compat
from IPython.utils.path import get_ipython_dir
@ -74,7 +73,7 @@ class ClusterManager(LoggingConfigurable):
def update_profiles(self):
"""List all profiles in the ipython_dir and cwd.
"""
for path in [get_ipython_dir(), os.getcwdu()]:
for path in [get_ipython_dir(), py3compat.getcwd()]:
for profile in list_profiles_in(path):
pd = self.get_profile_dir(profile, path)
if profile not in self.profiles:

View File

@ -21,7 +21,8 @@ import os
from IPython.config.configurable import LoggingConfigurable
from IPython.nbformat import current
from IPython.utils.traitlets import List, Dict, Unicode, TraitError
from IPython.utils import py3compat
from IPython.utils.traitlets import Unicode, TraitError
#-----------------------------------------------------------------------------
# Classes
@ -35,7 +36,7 @@ class NotebookManager(LoggingConfigurable):
# 2. The cwd of the kernel for a project.
# Right now we use this attribute in a number of different places and
# we are going to have to disentangle all of this.
notebook_dir = Unicode(os.getcwdu(), config=True, help="""
notebook_dir = Unicode(py3compat.getcwd(), config=True, help="""
The directory to use for notebooks.
""")