mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove use of Python 2 os.getcwdu()
os.getcwdu() is Python 2 only. It was removed from Python 3. As Sphinx is now Python 3 only, can remove the workaround. $ python2 -c 'import os; print(os.getcwdu)' <built-in function getcwdu> $ python3 -c 'import os; print(os.getcwdu)' Traceback (most recent call last): File "<string>", line 1, in <module> AttributeError: module 'os' has no attribute 'getcwdu' sphinx.util.osutil.getcwd() is now deprecated for removal.
This commit is contained in:
parent
ffaa528c98
commit
1d11a297a3
@ -9,12 +9,13 @@
|
|||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
from docutils.utils import relative_path
|
from docutils.utils import relative_path
|
||||||
|
|
||||||
from sphinx.environment.collectors import EnvironmentCollector
|
from sphinx.environment.collectors import EnvironmentCollector
|
||||||
from sphinx.util.osutil import getcwd, fs_encoding
|
from sphinx.util.osutil import fs_encoding
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
# For type annotation
|
# For type annotation
|
||||||
@ -40,7 +41,7 @@ class DependenciesCollector(EnvironmentCollector):
|
|||||||
def process_doc(self, app, doctree):
|
def process_doc(self, app, doctree):
|
||||||
# type: (Sphinx, nodes.Node) -> None
|
# type: (Sphinx, nodes.Node) -> None
|
||||||
"""Process docutils-generated dependency info."""
|
"""Process docutils-generated dependency info."""
|
||||||
cwd = getcwd()
|
cwd = os.getcwd()
|
||||||
frompath = path.join(path.normpath(app.srcdir), 'dummy')
|
frompath = path.join(path.normpath(app.srcdir), 'dummy')
|
||||||
deps = doctree.settings.record_dependencies
|
deps = doctree.settings.record_dependencies
|
||||||
if not deps:
|
if not deps:
|
||||||
|
@ -25,7 +25,7 @@ from os import path
|
|||||||
|
|
||||||
from six import PY2, PY3, text_type
|
from six import PY2, PY3, text_type
|
||||||
|
|
||||||
from sphinx.deprecation import RemovedInSphinx30Warning
|
from sphinx.deprecation import RemovedInSphinx30Warning, RemovedInSphinx40Warning
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
# For type annotation
|
# For type annotation
|
||||||
@ -243,15 +243,16 @@ def abspath(pathdir):
|
|||||||
|
|
||||||
def getcwd():
|
def getcwd():
|
||||||
# type: () -> unicode
|
# type: () -> unicode
|
||||||
if hasattr(os, 'getcwdu'):
|
warnings.warn('sphinx.util.osutil.getcwd() is deprecated. '
|
||||||
return os.getcwdu()
|
'Please use os.getcwd() instead.',
|
||||||
|
RemovedInSphinx40Warning)
|
||||||
return os.getcwd()
|
return os.getcwd()
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def cd(target_dir):
|
def cd(target_dir):
|
||||||
# type: (unicode) -> Iterator[None]
|
# type: (unicode) -> Iterator[None]
|
||||||
cwd = getcwd()
|
cwd = os.getcwd()
|
||||||
try:
|
try:
|
||||||
os.chdir(target_dir)
|
os.chdir(target_dir)
|
||||||
yield
|
yield
|
||||||
|
Loading…
Reference in New Issue
Block a user