diff options
author | Helmut Grohne <helmut@subdivi.de> | 2025-05-20 12:05:28 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2025-05-20 12:05:28 +0200 |
commit | 3d16d57bf63f18b46dd7c440fefa3e9fb8c112f0 (patch) | |
tree | 7ce07c6b2564274fdc793a98faa2dac630bb4f9f | |
parent | 68d7e2a4478ed06a161f894262dbba0824261e30 (diff) | |
download | python-linuxnamespaces-3d16d57bf63f18b46dd7c440fefa3e9fb8c112f0.tar.gz |
AtLocation.chdir: FileDescriptor already is a context manager
-rw-r--r-- | linuxnamespaces/atlocation.py | 5 |
1 files 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) |