8000 Use ``package_dir`` in ``sphinx.locale`` · sphinx-doc/sphinx@8b23ca0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8b23ca0

Browse files
committed
Use package_dir in sphinx.locale
1 parent 4daa038 commit 8b23ca0

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

sphinx/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@
3838

3939
try:
4040
if ret := subprocess.run(
41-
['git', 'rev-parse', '--short', 'HEAD'], # NoQA: S607
41+
('git', 'rev-parse', '--short', 'HEAD'),
4242
cwd=package_dir,
43-
capture_output=True,
4443
check=False,
45-
encoding='ascii',
44+
encoding='utf-8',
4645
errors='surrogateescape',
46+
stdout=True,
4747
).stdout:
48-
__display_version__ += '+/' + ret.strip()
48+
__display_version__ += f'+/{ret.strip()}'
4949
del ret
5050
finally:
5151
del subprocess

sphinx/locale/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
from pathlib import Path
99
from typing import TYPE_CHECKING
1010

11+
from sphinx import package_dir
12+
1113
if TYPE_CHECKING:
1214
import os
1315
from collections.abc import Callable, Iterable
1416
from typing import Any
1517

18+
_LOCALE_DIR = Path(package_dir, 'locale')
19+
1620

1721
class _TranslationProxy:
1822
"""The proxy implementation attempts to be as complete as possible, so that
@@ -140,9 +144,6 @@ def init(
140144
return translator, has_translation
141145

142146

143-
_LOCALE_DIR = Path(__file__).resolve().parent
144-
145-
146147
def init_console(
147148
locale_dir: str | os.PathLike[str] | None = None,
148149
catalog: str = 'sphinx',

0 commit comments

Comments
 (0)
0