From 3d16d57bf63f18b46dd7c440fefa3e9fb8c112f0 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Tue, 20 May 2025 12:05:28 +0200 Subject: AtLocation.chdir: FileDescriptor already is a context manager --- linuxnamespaces/atlocation.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linuxnamespaces/atlocation.py b/linuxnamespaces/atlocation.py index a4255a6..0003c35 100644 --- a/linuxnamespaces/atlocation.py +++ b/linuxnamespaces/atlocation.py @@ -7,7 +7,6 @@ to work with a location described in this way and this module provides support code for doing so. """ -import contextlib import enum import errno import os @@ -221,8 +220,8 @@ class AtLocation: assert self.location if self.fd == AT_FDCWD: return os.chdir(self.location) - with contextlib.closing( - FileDescriptor(self.open(flags=os.O_PATH | os.O_CLOEXEC)) + with FileDescriptor( + self.open(flags=os.O_PATH | os.O_CLOEXEC) ) as dirfd: return os.fchdir(dirfd) -- cgit v1.2.3