[Git][reproducible-builds/diffoscope][master] 2 commits: Prevent a traceback when comparing two .rdx files directly as get_member will...
Chris Lamb
gitlab at salsa.debian.org
Thu Mar 5 19:30:44 UTC 2020
Chris Lamb pushed to branch master at Reproducible Builds / diffoscope
Commits:
6344b5af by Chris Lamb at 2020-03-05T11:30:17-08:00
Prevent a traceback when comparing two .rdx files directly as get_member will return a file even if the file is missing and not raise a KeyError exception; we therefore explicitly test for the existence of the file.
- - - - -
5840c56f by Chris Lamb at 2020-03-05T11:30:17-08:00
Don't allow errors within Rscript deserialisation cause the entire operation to fail, for example if an external library cannot be loaded. (Closes: reproducible-builds/diffoscope#91)
- - - - -
1 changed file:
- diffoscope/comparators/rdata.py
Changes:
=====================================
diffoscope/comparators/rdata.py
=====================================
@@ -38,6 +38,14 @@ RDS_HEADERS = {
DUMP_RDB = rb"""
hideOutput = lazyLoad(commandArgs(TRUE));
+safeDeparse <- function(obj) {
+ tryCatch({
+ deparse(obj)
+ }, error = function (e) {
+ (deparse(e))
+ });
+}
+
for (x in ls(all.names = TRUE, sorted = TRUE)) {
obj = get(x)
@@ -47,11 +55,11 @@ for (x in ls(all.names = TRUE, sorted = TRUE)) {
cat("\n{\n", sep = "");
for (y in ls(obj, all.names = TRUE, sorted = TRUE)) {
obj2 = get(y, envir = obj);
- cat(sprintf(" \"%s\" = \"%s\"\n", y, deparse(obj2)), sep = "");
+ cat(sprintf(" \"%s\" = \"%s\"\n", y, safeDeparse(obj2)), sep = "");
}
cat("}\n");
} else {
- for (line in deparse(obj))
+ for (line in safeDeparse(obj))
cat(line, "\n", sep = "");
}
cat("\n");
@@ -86,17 +94,17 @@ def get_module_path_for_rdb(rdb):
# Calculate location of parallel .rdx file
rdx_name = "{}.rdx".format(os.path.splitext(rdb.name)[0])
- try:
- # Query the container for the full path (eg. `./path/to/foo.rdx`)...
- rdx = rdb.container.get_member(rdx_name)
- except KeyError:
- try:
- # ... falling back to looking in the same directory for when
- # comparing two .rdb files directly
- rdx = rdb.container.get_member(os.path.basename(rdx_name))
- except KeyError:
- # Corresponding .rdx does not exist
- return
+ # Query the container for the full path (eg. `./path/to/foo.rdx`)...
+ rdx = rdb.container.get_member(rdx_name)
+
+ if not os.path.exists(rdx.path):
+ # ... falling back to looking in the same directory for when
+ # comparing two .rdb files directly
+ rdx = rdb.container.get_member(os.path.basename(rdx_name))
+
+ if not os.path.exists(rdx.path):
+ # Corresponding .rdx does not exist
+ return
temp_dir = get_temporary_directory().name
prefix = os.path.join(temp_dir, "temp")
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/b1a71c2f62ada4b3847f206231f89f19a0d16733...5840c56f5591f6eed4426b8a79cd5cd8661f2be5
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/b1a71c2f62ada4b3847f206231f89f19a0d16733...5840c56f5591f6eed4426b8a79cd5cd8661f2be5
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20200305/dcb97379/attachment.htm>
More information about the rb-commits
mailing list