Skip to content

Commit dc303d2

Browse files
Make it an error everywhere, not warning
1 parent efdd6d7 commit dc303d2

File tree

8 files changed

+11
-21
lines changed

8 files changed

+11
-21
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ S3method(edit, data.table)
199199
export(format_col)
200200
S3method(format_col, default)
201201
S3method(format_col, POSIXct)
202-
S3method(format_col, POSIXlt)
203202
S3method(format_col, expression)
204203
export(format_list_item)
205204
S3method(format_list_item, default)

R/data.table.R

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,15 +2918,13 @@ setDT = function(x, keep.rownames=FALSE, key=NULL, check.names=FALSE) {
29182918
} else if (is.data.frame(x)) {
29192919
# check no matrix-like columns, #3760. Allow a single list(matrix) is unambiguous and depended on by some revdeps, #3581
29202920
# for performance, only warn on the first such column, #5426
2921-
test_matrix_column = test_posixl_column = TRUE
29222921
for (jj in seq_along(x)) {
29232922
if (test_posixl_column && inherits(x[[jj]], "POSIXlt")) {
2924-
.Call(Cwarn_posixl_column_r, jj)
2925-
test_posixl_column = FALSE
2923+
.Call(Cerr_posixl_column_r, jj)
29262924
}
29272925
if (test_matrix_column && length(dim(x[[jj]])) > 1L) {
29282926
.Call(Cwarn_matrix_column_r, jj)
2929-
test_matrix_column = FALSE
2927+
break
29302928
}
29312929
}
29322930

R/print.data.table.R

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,6 @@ format_col.POSIXct = function(x, ..., timezone=FALSE) {
213213
x
214214
}
215215

216-
format_col.POSIXlt = function(x, ...) {
217-
names(x) = names(unclass(as.POSIXlt(Sys.time())))
218-
format_col(as.POSIXct(x), ...)
219-
}
220-
221216
# #3011 -- expression columns can wrap to newlines which breaks printing
222217
format_col.expression = function(x, ...) format(char.trunc(as.character(x)), ...)
223218

inst/tests/tests.Rraw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8655,7 +8655,7 @@ dt = data.table(d1="1984-03-17")
86558655
ans = data.table(d1="1984-03-17", d2=as.POSIXct("1984-03-17", tz='UTC'))
86568656
test(1612.2, dt[, d2 := strptime(d1, "%Y-%m-%d", tz='UTC')], ans, warning="POSIXlt detected and converted to POSIXct")
86578657
ll = list(a=as.POSIXlt("2015-01-01"), b=2L)
8658-
test(1612.3, setDT(ll), ll, warning="Column 1 has class 'POSIXlt'")
8658+
test(1612.3, setDT(ll), error="Column 1 has class 'POSIXlt'")
86598659

86608660
# tests for all.equal.data.table #1106
86618661
# diff nrow

src/assign.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,15 @@ void warn_matrix_column(/* 1-indexed */ int i) {
203203
warning(_("Some columns are a multi-column type (such as a matrix column), for example column %d. setDT will retain these columns as-is but subsequent operations like grouping and joining may fail. Please consider as.data.table() instead which will create a new column for each embedded column."), i);
204204
}
205205

206-
void warn_posixl_column(/* 1-indexed */ int i) {
207-
warning(_("Column %d has class 'POSIXlt'. setDT will retain these columns as-is but subsequent operations may fail. We do not recommend the use of POSIXlt at all because it uses 40 bytes to store one date. Please consider as.data.table() instead which will convert to POSIXct."), i);
206+
void err_posixl_column(/* 1-indexed */ int i) {
207+
error(_("Column %d has class 'POSIXlt'. Please convert it to POSIXct (using as.POSIXct) and run setDT() again, or use as.data.table() instead. We do not recommend the use of POSIXlt at all because it uses 40 bytes to store one date."), i);
208208
}
209209

210210
// input validation for setDT() list input; assume is.list(x) was tested in R
211211
SEXP setdt_nrows(SEXP x)
212212
{
213213
int base_length = 0;
214214
bool test_matrix_cols = true;
215-
bool test_posixl_cols = true;
216215

217216
for (R_len_t i = 0; i < LENGTH(x); ++i) {
218217
SEXP xi = VECTOR_ELT(x, i);
@@ -238,8 +237,7 @@ SEXP setdt_nrows(SEXP x)
238237
}
239238
len_xi = INTEGER(dim_xi)[0];
240239
} else {
241-
// Be sure to do length() dispatch, #4800
242-
len_xi = length_with_dispatch(xi);
240+
len_xi = LENGTH(xi);
243241
}
244242
if (!base_length) {
245243
base_length = len_xi;

src/data.table.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ SEXP alloccol(SEXP dt, R_len_t n, Rboolean verbose);
182182
const char *memrecycle(const SEXP target, const SEXP where, const int start, const int len, SEXP source, const int sourceStart, const int sourceLen, const int colnum, const char *colname);
183183
SEXP shallowwrapper(SEXP dt, SEXP cols);
184184
void warn_matrix_column(int i);
185-
void warn_posixl_column(int i);
185+
void err_posixl_column(int i);
186186

187187
SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols,
188188
SEXP xjiscols, SEXP grporder, SEXP order, SEXP starts,
@@ -330,7 +330,7 @@ SEXP gfirst(SEXP);
330330
SEXP gnthvalue(SEXP, SEXP);
331331
SEXP dim(SEXP);
332332
SEXP warn_matrix_column_r(SEXP);
333-
SEXP warn_posixl_column_r(SEXP);
333+
SEXP err_posixl_column_r(SEXP);
334334
SEXP gvar(SEXP, SEXP);
335335
SEXP gsd(SEXP, SEXP);
336336
SEXP gprod(SEXP, SEXP);

src/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ R_CallMethodDef callMethods[] = {
151151
{"CconvertDate", (DL_FUNC)&convertDate, -1},
152152
{"Cnotchin", (DL_FUNC)&notchin, -1},
153153
{"Cwarn_matrix_column_r", (DL_FUNC)&warn_matrix_column_r, -1},
154-
{"Cwarn_posixl_column_r", (DL_FUNC)&warn_posixl_column_r, -1},
154+
{"Cerr_posixl_column_r", (DL_FUNC)&err_posixl_column_r, -1},
155155
{NULL, NULL, 0}
156156
};
157157

src/wrappers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ SEXP warn_matrix_column_r(SEXP i) {
126126
return R_NilValue;
127127
}
128128

129-
SEXP warn_posixl_column_r(SEXP i) {
130-
warn_posixl_column(INTEGER(i)[0]);
129+
SEXP err_posixl_column_r(SEXP i) {
130+
err_posixl_column(INTEGER(i)[0]);
131131
return R_NilValue;
132132
}

0 commit comments

Comments
 (0)