mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
Use subprocess.DEVNULL
This commit is contained in:
parent
3500334338
commit
ccf1efb3ef
|
@ -7,7 +7,6 @@ Based on https://github.com/jaraco/rst.linker, with thanks to Jason R. Coombs.
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
@ -22,11 +21,10 @@ VERSION_TITLE_REGEX = re.compile(r"^(\d+\.\d+\.\d+)\n-+\n")
|
||||||
def get_date_for(git_version: str) -> dt.datetime | None:
|
def get_date_for(git_version: str) -> dt.datetime | None:
|
||||||
cmd = ["git", "log", "-1", "--format=%ai", git_version]
|
cmd = ["git", "log", "-1", "--format=%ai", git_version]
|
||||||
try:
|
try:
|
||||||
with open(os.devnull, "w", encoding="utf-8") as devnull:
|
out = subprocess.check_output(
|
||||||
out = subprocess.check_output(
|
cmd, stderr=subprocess.DEVNULL, text=True, encoding="utf-8"
|
||||||
cmd, stderr=devnull, text=True, encoding="utf-8"
|
)
|
||||||
)
|
ts = out.strip()
|
||||||
ts = out.strip()
|
|
||||||
return dt.datetime.fromisoformat(ts)
|
return dt.datetime.fromisoformat(ts)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user