浏览代码

Merge pull request #8685 from 120EE0980/replace-assert

quickfix :  borg exits when assertions are disabled with Python optimizations
TW 2 月之前
父节点
当前提交
d892bca8b9
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      src/borg/archiver.py

+ 9 - 0
src/borg/archiver.py

@@ -3,6 +3,15 @@
 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 collections