aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2020-01-20 13:20:42 +1000
committerteor <teor@torproject.org>2020-01-20 13:27:40 +1000
commit28c8c63de96f82818b3ce40c027beb73519000da (patch)
treefc009128e72391c2a1c518ba5e9eefdeee2ed5ce /scripts
parent2c75d4a8d0bea2e9c0ebd5ef07b6f9149ce135cb (diff)
downloadtor-28c8c63de96f82818b3ce40c027beb73519000da.tar.gz
tor-28c8c63de96f82818b3ce40c027beb73519000da.zip
add_c_file: Replace asserts with exceptions
Closes 32962.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/maint/add_c_file.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/scripts/maint/add_c_file.py b/scripts/maint/add_c_file.py
index 75e1f556b8..e1e224d8d5 100755
--- a/scripts/maint/add_c_file.py
+++ b/scripts/maint/add_c_file.py
@@ -268,15 +268,26 @@ def run(fname):
# Make sure we're in the top-level tor directory,
# which contains the src directory
- assert(os.path.isdir("src"))
+ if not os.path.isdir("src"):
+ raise RuntimeError("Could not find './src/'. "
+ "Run this script from the top-level tor source "
+ "directory.")
+
# And it looks like a tor/src directory
- assert(os.path.isfile("src/include.am"))
+ if not os.path.isfile("src/include.am"):
+ raise RuntimeError("Could not find './src/include.am'. "
+ "Run this script from the top-level tor source "
+ "directory.")
# Make the file name relative to the top-level tor directory
tor_fname = tordir_file(fname)
# And check that we're adding files to the "src" directory,
# with canonical paths
- assert(tor_fname[:4] == "src/")
+ if tor_fname[:4] != "src/":
+ raise ValueError("Requested file path '{}' canonicalized to '{}', "
+ "but the canonical path did not start with 'src/'. "
+ "Please add files to the src directory."
+ .format(fname, tor_fname))
c_tor_fname = makeext(tor_fname, "c")
h_tor_fname = makeext(tor_fname, "h")