diff --git a/NEWS.md b/NEWS.md index f2d994bf1..7357f9d4b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,16 +18,6 @@ 2. `[,showProgress=]` and `options(datatable.showProgress)` now accept an integer to control the progress bar update interval in seconds, allowing finer control over progress reporting frequency; `TRUE` uses the default 3-second interval, [#6514](https://github.com/Rdatatable/data.table/issues/6514). Thanks @ethanbsmith for the report and @ben-schwen for the PR. -### Notes - -1. {data.table} now depends on R 3.5.0 (2018). - -2. pydatatable compatibility layer in `fread()` and `fwrite()` has been removed, [#7069](https://github.com/Rdatatable/data.table/issues/7069). Thanks @badasahog for the report and the PR. - -3. Vignettes are now built using `litedown` instead of `knitr`, [#6394](https://github.com/Rdatatable/data.table/issues/6394). Thanks @jangorecki for the suggestion and @ben-schwen and @aitap for the implementation. - -4. Removed use of non-API macros `ATTRIB`, `SET_ATTRIB`, [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks @aitap for the continued assiduous work here. - ### BUG FIXES 1. `fread()` with `skip=0` and `(header=TRUE|FALSE)` no longer skips the first row when it has fewer fields than subsequent rows, [#7463](https://github.com/Rdatatable/data.table/issues/7463). Thanks @emayerhofer for the report and @ben-schwen for the fix. @@ -38,6 +28,16 @@ 4. `sum()` by group is correct with missing entries and GForce activated ([#7571](https://github.com/Rdatatable/data.table/issues/7571)). Thanks to @rweberc for the report and @manmita for the fix. The issue was caused by a faulty early `break` that spilled between groups, and resulted in silently incorrect results! +### Notes + +1. {data.table} now depends on R 3.5.0 (2018). + +2. pydatatable compatibility layer in `fread()` and `fwrite()` has been removed, [#7069](https://github.com/Rdatatable/data.table/issues/7069). Thanks @badasahog for the report and the PR. + +3. Vignettes are now built using `litedown` instead of `knitr`, [#6394](https://github.com/Rdatatable/data.table/issues/6394). Thanks @jangorecki for the suggestion and @ben-schwen and @aitap for the implementation. + +4. Removed use of non-API `ATTRIB`, `SET_ATTRIB`, and `findVar` [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks @aitap for the continued assiduous work here, and @MichaelChirico for the easy fix to replace `findVar` with `R_getVar`. + ## data.table [v1.18.0](https://github.com/Rdatatable/data.table/milestone/37?closed=1) 23 December 2025 ### BREAKING CHANGE diff --git a/src/data.table.h b/src/data.table.h index a7f787258..d6c67c752 100644 --- a/src/data.table.h +++ b/src/data.table.h @@ -14,6 +14,7 @@ # define LOGICAL_RO LOGICAL #endif #if R_VERSION < R_Version(4, 5, 0) +# define R_getVar(x, env, inherits) findVar(x, env) # define isDataFrame(x) isFrame(x) // #6180 # define CLEAR_ATTRIB(x) SET_ATTRIB(x, R_NilValue) # define ANY_ATTRIB(x) (!(isNull(ATTRIB(x)))) diff --git a/src/dogroups.c b/src/dogroups.c index 773f40b99..5d270ef4a 100644 --- a/src/dogroups.c +++ b/src/dogroups.c @@ -94,8 +94,8 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX ngrpcols = length(grpcols); nrowgroups = length(VECTOR_ELT(groups,0)); // fix for longstanding FR/bug, #495. E.g., DT[, c(sum(v1), lapply(.SD, mean)), by=grp, .SDcols=v2:v3] resulted in error.. the idea is, 1) we create .SDall, which is normally == .SD. But if extra vars are detected in jexp other than .SD, then .SD becomes a shallow copy of .SDall with only .SDcols in .SD. Since internally, we don't make a copy, changing .SDall will reflect in .SD. Hopefully this'll workout :-). - SEXP SDall = PROTECT(findVar(install(".SDall"), env)); nprotect++; // PROTECT for rchk - SEXP SD = PROTECT(findVar(install(".SD"), env)); nprotect++; + SEXP SDall = PROTECT(R_getVar(install(".SDall"), env, false)); nprotect++; // PROTECT for rchk + SEXP SD = PROTECT(R_getVar(install(".SD"), env, false)); nprotect++; int updateTime = INTEGER(showProgressArg)[0]; const bool showProgress = updateTime > 0 && ngrp > 1; // showProgress only if more than 1 group @@ -125,12 +125,12 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX error("!length(bynames)[%d]==length(groups)[%d]==length(grpcols)[%d]", length(bynames), length(groups), length(grpcols)); // # notranslate // TO DO: check this check above. - N = PROTECT(findVar(install(".N"), env)); nprotect++; // PROTECT for rchk + N = PROTECT(R_getVar(install(".N"), env, false)); nprotect++; // PROTECT for rchk hash_set(specials, N, -1); // marker for anySpecialStatic(); see its comments - GRP = PROTECT(findVar(install(".GRP"), env)); nprotect++; + GRP = PROTECT(R_getVar(install(".GRP"), env, false)); nprotect++; hash_set(specials, GRP, -1); // marker for anySpecialStatic(); see its comments - iSD = PROTECT(findVar(install(".iSD"), env)); nprotect++; // 1-row and possibly no cols (if no i variables are used via JIS) - xSD = PROTECT(findVar(install(".xSD"), env)); nprotect++; + iSD = PROTECT(R_getVar(install(".iSD"), env, false)); nprotect++; // 1-row and possibly no cols (if no i variables are used via JIS) + xSD = PROTECT(R_getVar(install(".xSD"), env, false)); nprotect++; R_len_t maxGrpSize = 0; const int *ilens = INTEGER(lens), n=LENGTH(lens); for (R_len_t i=0; i