diff --git a/R/data.table.R b/R/data.table.R index 424dcddb55..a1e91ae814 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -137,7 +137,10 @@ print.data.table <- function(x, is.formula <- function(x) class(x) == "formula" format.data.table <- function (x, ..., justify="none") { - format.item <- function(x) { + if (is.atomic(x) && !is.null(x)) { + stop("Internal structure doesn't seem to be a list. Possibly corrupt data.table.") + } + format.item <- function(x) { if (is.atomic(x) || is.formula(x)) # FR #2591 - format.data.table issue with columns of class "formula" paste(c(format(head(x,6), justify=justify, ...), if(length(x)>6)""),collapse=",") # fix for #5435 - format has to be added here... else diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 03eb94ced0..3e04e2706a 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -5982,7 +5982,11 @@ test(1486.2, as.data.frame(ans2.1), as.data.frame(ans2.1)) # Fix for #832 x <- matrix(1:9, ncol=3) setattr(x, "names", paste("V", seq_len(length(x)), sep = "")) -test(1486.3, setattr(x, "class", c("data.table", "data.frame")), error="Internal structure doesn't seem to be a list") +test(1487.1, setattr(x, "class", c("data.table", "data.frame")), error="Internal structure doesn't seem to be a list") +x <- matrix(1:9, ncol=3) +class(x) = c("data.table", "data.frame") +# not sure how to test this one, so using `tryCatch` +test(1487.2, tryCatch(print(x), error=function(k) "bla"), "bla") ##########################