Skip to content

Commit

Permalink
fix: adds encoding to open calls
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanker committed Dec 6, 2023
1 parent da69dcb commit 110ff36
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/invert4geom/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def available_cpu_count() -> typing.Any:
# cpuset may restrict the number of *available* processors
try:
# m = re.search(r"(?m)^Cpus_allowed:\s*(.*)$", open("/proc/self/status").read())
with pathlib.Path("/proc/self/status").open() as f: # pylint: disable=unspecified-encoding
with pathlib.Path("/proc/self/status").open(encoding="utf8") as f:
m = re.search(r"(?m)^Cpus_allowed:\s*(.*)$", f.read())
if m:
res = bin(int(m.group(1).replace(",", ""), 16)).count("1")
Expand Down Expand Up @@ -138,7 +138,7 @@ def available_cpu_count() -> typing.Any:
# Linux
try:
# res = open("/proc/cpuinfo").read().count("processor\t:")
with pathlib.Path("/proc/cpuinfo").open() as f: # pylint: disable=unspecified-encoding
with pathlib.Path("/proc/cpuinfo").open(encoding="utf8") as f:
res = f.read().count("processor\t:")

if res > 0:
Expand All @@ -163,7 +163,7 @@ def available_cpu_count() -> typing.Any:
try:
try:
# dmesg = open("/var/run/dmesg.boot").read()
with pathlib.Path("/var/run/dmesg.boot").open() as f: # pylint: disable=unspecified-encoding
with pathlib.Path("/var/run/dmesg.boot").open(encoding="utf8") as f:
dmesg = f.read()
# dmesg = pathlib.Path("/var/run/dmesg.boot").open().read()
except OSError:
Expand Down

0 comments on commit 110ff36

Please sign in to comment.