Skip to content

Commit fb62784

Browse files
committed
Use pathlib to open the file
1 parent b35394a commit fb62784

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

setuptools/config/expand.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import importlib
2222
import io
2323
import os
24+
import pathlib
2425
import sys
2526
import warnings
2627
from glob import iglob
@@ -62,9 +63,7 @@ class StaticModule:
6263
"""Proxy to a module object that avoids executing arbitrary code."""
6364

6465
def __init__(self, name: str, spec: ModuleSpec):
65-
with open(spec.origin, mode='rb') as strm: # type: ignore
66-
src = strm.read()
67-
module = ast.parse(src)
66+
module = ast.parse(pathlib.Path(spec.origin).read_bytes())
6867
vars(self).update(locals())
6968
del self.self
7069

0 commit comments

Comments
 (0)