Skip to content

Commit

Permalink
get rid of some rare error classes, use RTError instead
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWaldmann committed Nov 13, 2023
1 parent f804b28 commit 7a1e429
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
4 changes: 0 additions & 4 deletions docs/internals/frontends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,6 @@ Errors
ErrorWithTraceback rc: 2 traceback: yes
Error: {}

ExtensionModuleError rc: 2 traceback: no
The Borg binary extension modules do not seem to be properly installed.
PythonLibcTooOld rc: 2 traceback: no
FATAL: this Python was compiled for a too old (g)libc and misses required functionality.
Buffer.MemoryLimitExceeded rc: 2 traceback: no
Requested buffer size {} is above the limit of {}.
EfficientCollectionQueue.SizeUnderflow rc: 2 traceback: no
Expand Down
25 changes: 9 additions & 16 deletions src/borg/helpers/checks.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
import os
import sys

from .errors import Error
from .errors import RTError
from ..platformflags import is_win32, is_linux, is_freebsd, is_darwin


class PythonLibcTooOld(Error):
"""FATAL: this Python was compiled for a too old (g)libc and misses required functionality."""


def check_python():
if is_win32:
required_funcs = {os.stat}
else:
required_funcs = {os.stat, os.utime, os.chown}
if not os.supports_follow_symlinks.issuperset(required_funcs):
raise PythonLibcTooOld


class ExtensionModuleError(Error):
"""The Borg binary extension modules do not seem to be properly installed."""
raise RTError("""FATAL: this Python was compiled for a too old (g)libc and misses required functionality.""")


def check_extension_modules():
import borg.crypto.low_level
from .. import platform, compress, item, chunker, hashindex
msg = """The Borg binary extension modules do not seem to be properly installed."""
if hashindex.API_VERSION != '1.2_01':
raise ExtensionModuleError
raise RTError(msg)
if chunker.API_VERSION != '1.2_01':
raise ExtensionModuleError
raise RTError(msg)
if compress.API_VERSION != '1.2_02':
raise ExtensionModuleError
raise RTError(msg)
if borg.crypto.low_level.API_VERSION != '1.2_01':
raise ExtensionModuleError
raise RTError(msg)
if item.API_VERSION != '1.2_01':
raise ExtensionModuleError
raise RTError(msg)
if platform.API_VERSION != platform.OS_API_VERSION or platform.API_VERSION != '1.2_05':
raise ExtensionModuleError
raise RTError(msg)

0 comments on commit 7a1e429

Please sign in to comment.