From 13b7e1f5a8ce5a81de702e244c602bcef294b68d Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 21 Apr 2025 17:44:20 +0200 Subject: [PATCH] quickfix to disallow running borg with assertions switched off, see #8649 forward port of #8685 to master branch. --- src/borg/archiver/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/borg/archiver/__init__.py b/src/borg/archiver/__init__.py index f8939f894..8b888b059 100644 --- a/src/borg/archiver/__init__.py +++ b/src/borg/archiver/__init__.py @@ -3,6 +3,17 @@ import sys import traceback +# quickfix to disallow running borg with assertions switched off +try: + assert False +except AssertionError: + pass # OK +else: + print( + "Borg requires working assertions. Please run Python without -O and/or unset PYTHONOPTIMIZE.", file=sys.stderr + ) + sys.exit(2) # == EXIT_ERROR + try: import argparse import faulthandler