Skip to content

Commit

Permalink
Fix EncodingWarning and ResourceWarning.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jul 29, 2023
1 parent 93eb6ca commit dea1e9d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions jaraco/services/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def exe(self):
args: List[str] = []
"Additional args to pass to the exe when testing for its suitability"

DEV_NULL = open(os.path.devnull, 'r+')

@classmethod
def resolve(cls):
"""
Expand Down Expand Up @@ -53,7 +51,8 @@ def find_valid_roots(cls):
def is_valid_root(cls, root):
try:
cmd = [os.path.join(root, cls.exe)] + cls.args
subprocess.check_call(cmd, stdout=cls.DEV_NULL)
with open(os.path.devnull, 'r+', encoding='utf-8') as null:
subprocess.check_call(cmd, stdout=null)
except OSError:
return False
return True

0 comments on commit dea1e9d

Please sign in to comment.