diff options
Diffstat (limited to 'platform_utils_win32.py')
-rw-r--r-- | platform_utils_win32.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/platform_utils_win32.py b/platform_utils_win32.py index 80a52639..f10d9d0a 100644 --- a/platform_utils_win32.py +++ b/platform_utils_win32.py | |||
@@ -186,9 +186,7 @@ def _create_symlink(source, link_name, dwFlags): | |||
186 | error_desc = FormatError(code).strip() | 186 | error_desc = FormatError(code).strip() |
187 | if code == ERROR_PRIVILEGE_NOT_HELD: | 187 | if code == ERROR_PRIVILEGE_NOT_HELD: |
188 | raise OSError(errno.EPERM, error_desc, link_name) | 188 | raise OSError(errno.EPERM, error_desc, link_name) |
189 | _raise_winerror( | 189 | _raise_winerror(code, f'Error creating symbolic link "{link_name}"') |
190 | code, 'Error creating symbolic link "{}"'.format(link_name) | ||
191 | ) | ||
192 | 190 | ||
193 | 191 | ||
194 | def islink(path): | 192 | def islink(path): |
@@ -210,7 +208,7 @@ def readlink(path): | |||
210 | ) | 208 | ) |
211 | if reparse_point_handle == INVALID_HANDLE_VALUE: | 209 | if reparse_point_handle == INVALID_HANDLE_VALUE: |
212 | _raise_winerror( | 210 | _raise_winerror( |
213 | get_last_error(), 'Error opening symbolic link "{}"'.format(path) | 211 | get_last_error(), f'Error opening symbolic link "{path}"' |
214 | ) | 212 | ) |
215 | target_buffer = c_buffer(MAXIMUM_REPARSE_DATA_BUFFER_SIZE) | 213 | target_buffer = c_buffer(MAXIMUM_REPARSE_DATA_BUFFER_SIZE) |
216 | n_bytes_returned = DWORD() | 214 | n_bytes_returned = DWORD() |
@@ -227,7 +225,7 @@ def readlink(path): | |||
227 | CloseHandle(reparse_point_handle) | 225 | CloseHandle(reparse_point_handle) |
228 | if not io_result: | 226 | if not io_result: |
229 | _raise_winerror( | 227 | _raise_winerror( |
230 | get_last_error(), 'Error reading symbolic link "{}"'.format(path) | 228 | get_last_error(), f'Error reading symbolic link "{path}"' |
231 | ) | 229 | ) |
232 | rdb = REPARSE_DATA_BUFFER.from_buffer(target_buffer) | 230 | rdb = REPARSE_DATA_BUFFER.from_buffer(target_buffer) |
233 | if rdb.ReparseTag == IO_REPARSE_TAG_SYMLINK: | 231 | if rdb.ReparseTag == IO_REPARSE_TAG_SYMLINK: |
@@ -236,11 +234,11 @@ def readlink(path): | |||
236 | return rdb.MountPointReparseBuffer.PrintName | 234 | return rdb.MountPointReparseBuffer.PrintName |
237 | # Unsupported reparse point type. | 235 | # Unsupported reparse point type. |
238 | _raise_winerror( | 236 | _raise_winerror( |
239 | ERROR_NOT_SUPPORTED, 'Error reading symbolic link "{}"'.format(path) | 237 | ERROR_NOT_SUPPORTED, f'Error reading symbolic link "{path}"' |
240 | ) | 238 | ) |
241 | 239 | ||
242 | 240 | ||
243 | def _raise_winerror(code, error_desc): | 241 | def _raise_winerror(code, error_desc): |
244 | win_error_desc = FormatError(code).strip() | 242 | win_error_desc = FormatError(code).strip() |
245 | error_desc = "{0}: {1}".format(error_desc, win_error_desc) | 243 | error_desc = f"{error_desc}: {win_error_desc}" |
246 | raise WinError(code, error_desc) | 244 | raise WinError(code, error_desc) |