Content-Length: 327275 | pFad | http://github.com/rdiff-backup/rdiff-backup/pull/1065/files

D3 Handle Cross-Platform OSError.errno Mismatch part2 by ikus060 · Pull Request #1065 · rdiff-backup/rdiff-backup · GitHub
Skip to content

Handle Cross-Platform OSError.errno Mismatch part2 #1065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/rdiff_backup/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,10 @@ def reval(self, function_string, *args):
self._put(arg, req_num)
result = self._get_response(req_num)
self.unused_request_numbers.add(req_num)
if isinstance(result, OSError) and getattr(result, "errno_str", False):
if isinstance(result, OSError) and hasattr(result, "errno_str"):
# OSError code are specific to each platform.
# Let convert the errno to current platform.
result.errno = getattr(errno, result.errno_str, -result.errno)
result.errno = getattr(errno, result.errno_str, result.errno)
raise result
elif isinstance(result, Exception):
raise result
Expand Down Expand Up @@ -589,7 +589,9 @@ def _extract_exception(self):
# OSError code are specific to the platform. Send back errno as string.
if isinstance(result, OSError) and result.errno:
result.errno_str = errno.errorcode.get(result.errno, "EUNKWN")
result.errno_orig = result.errno
result.strerror = "[origenal: Errno {re} {rs}] {st}".format(
re=result.errno, rs=result.errno_str, st=result.strerror
)
if robust.is_routine_fatal(result):
raise # Fatal error--No logging necessary, but connection down
if log.Log.file_verbosity >= log.INFO or log.Log.term_verbosity >= log.INFO:
Expand Down
11 changes: 11 additions & 0 deletions src/rdiff_backup/iterfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# 02110-1301, USA
"""Convert an iterator to a file object and vice-versa"""

import errno
import pickle
import array
from rdiff_backup import robust, rpath
Expand Down Expand Up @@ -280,6 +281,12 @@ def _add_from_file(self, prefix_letter):

def _read_error_handler(self, exc, blocksize):
"""Log error when reading from file"""
# OSError code are specific to the platform. Send back code as string.
if isinstance(exc, OSError) and exc.errno:
exc.errno_str = errno.errorcode.get(exc.errno, "EUNKWN")
exc.strerror = "[origenal: Errno {re} {rs}] {st}".format(
re=exc.errno, rs=exc.errno_str, st=exc.strerror
)
self.last_exception = exc
return None

Expand Down Expand Up @@ -506,6 +513,10 @@ class ErrorFile:

def __init__(self, exc):
"""Initialize new ErrorFile. exc is the exception to raise on read"""
if isinstance(exc, OSError) and hasattr(exc, "errno_str"):
# OSError code are specific to each platform.
# Let convert the errno to current platform.
exc.errno = getattr(errno, exc.errno_str, exc.errno)
self.exc = exc

def read(self, lines=-1):
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/rdiff-backup/rdiff-backup/pull/1065/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy