From fb62784d242fdeb38d06c4d1d8277c25775e7fca Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 29 Sep 2022 19:39:22 -0400 Subject: [PATCH] Use pathlib to open the file --- setuptools/config/expand.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setuptools/config/expand.py b/setuptools/config/expand.py index 693b2dbc30..38eb3db7d8 100644 --- a/setuptools/config/expand.py +++ b/setuptools/config/expand.py @@ -21,6 +21,7 @@ import importlib import io import os +import pathlib import sys import warnings from glob import iglob @@ -62,9 +63,7 @@ class StaticModule: """Proxy to a module object that avoids executing arbitrary code.""" def __init__(self, name: str, spec: ModuleSpec): - with open(spec.origin, mode='rb') as strm: # type: ignore - src = strm.read() - module = ast.parse(src) + module = ast.parse(pathlib.Path(spec.origin).read_bytes()) vars(self).update(locals()) del self.self