diff --git a/DESCRIPTION b/DESCRIPTION index 09c0e79e2..fd84de697 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,7 +44,7 @@ Suggests: Enhances: winch Encoding: UTF-8 -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Roxygen: list(markdown = TRUE) URL: https://rlang.r-lib.org, https://github.com/r-lib/rlang BugReports: https://github.com/r-lib/rlang/issues diff --git a/NEWS.md b/NEWS.md index d88a55d41..d9e0aabae 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,11 @@ # rlang (development version) +* `env_browse()` and `env_is_browsed()` are now defunct as they require an API + that is no longer available to packages (#1727). + * `env_unlock()` is now defunct because recent versions of R no long - make it possible to unlock an environment. Make sure to use an up-to-date - version of pkgload (>= 1.4.0) following this change. + make it possible to unlock an environment (#1705). Make sure to use an + up-to-date version of pkgload (>= 1.4.0) following this change. # rlang 1.1.4 diff --git a/R/env.R b/R/env.R index dfdfc875f..4a5bd24f1 100644 --- a/R/env.R +++ b/R/env.R @@ -566,8 +566,8 @@ env_is_locked <- function(env) { env_unlock <- function(env) { msg <- "`env_unlock()` is defunct as of rlang 1.1.5" - old_pkgload_running <- - "pkgload" %in% loadedNamespaces() && + old_pkgload_running <- + "pkgload" %in% loadedNamespaces() && some(sys.frames(), function(env) identical(topenv(env), ns_env("pkgload"))) && utils::packageVersion("pkgload") <= "1.3.4" @@ -754,6 +754,8 @@ str.rlang_envs <- function(object, ...) { #' #' @description #' +#' `r lifecycle::badge("defunct")` +#' #' * `env_browse(env)` is equivalent to evaluating `browser()` in #' `env`. It persistently sets the environment for step-debugging. #' Supply `value = FALSE` to disable browsing. @@ -767,12 +769,12 @@ str.rlang_envs <- function(object, ...) { #' `env_is_browsed()` (a logical), invisibly. #' @export env_browse <- function(env, value = TRUE) { - invisible(.Call(ffi_env_browse, env, value)) + abort("`env_browse()` is defunct as of rlang 1.2.0 because R no longer supports it") } #' @rdname env_browse #' @export env_is_browsed <- function(env) { - .Call(ffi_env_is_browsed, env) + abort("`env_is_browsed()` is defunct as of rlang 1.2.0 because R no longer supports it") } #' Is frame environment user facing? diff --git a/man/env_browse.Rd b/man/env_browse.Rd index c3a73c769..ad41cf4b4 100644 --- a/man/env_browse.Rd +++ b/man/env_browse.Rd @@ -19,6 +19,7 @@ env_is_browsed(env) \code{env_is_browsed()} (a logical), invisibly. } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#defunct}{\figure{lifecycle-defunct.svg}{options: alt='[Defunct]'}}}{\strong{[Defunct]}} \itemize{ \item \code{env_browse(env)} is equivalent to evaluating \code{browser()} in \code{env}. It persistently sets the environment for step-debugging. diff --git a/src/internal/exported.c b/src/internal/exported.c index 5e13cbf6a..9623a3453 100644 --- a/src/internal/exported.c +++ b/src/internal/exported.c @@ -511,26 +511,6 @@ r_obj* ffi_env_bind_list(r_obj* env, r_obj* names, r_obj* data) { return r_null; } -r_obj* ffi_env_browse(r_obj* env, r_obj* value) { - if (r_typeof(env) != R_TYPE_environment) { - r_abort("`env` must be an environment."); - } - if (!r_is_bool(value)) { - r_abort("`value` must be a single logical value."); - } - - r_obj* old = r_lgl(RDEBUG(env)); - SET_RDEBUG(env, r_lgl_get(value, 0)); - return old; -} - -r_obj* ffi_env_is_browsed(r_obj* env) { - if (r_typeof(env) != R_TYPE_environment) { - r_abort("`env` must be an environment."); - } - return r_lgl(RDEBUG(env)); -} - r_obj* ffi_ns_registry_env(void) { return R_NamespaceRegistry; } diff --git a/src/internal/init.c b/src/internal/init.c index 88588cc94..7688ce414 100644 --- a/src/internal/init.c +++ b/src/internal/init.c @@ -74,7 +74,6 @@ static const R_CallMethodDef r_callables[] = { {"ffi_env_bind", (DL_FUNC) &ffi_env_bind, 5}, {"ffi_env_bind_list", (DL_FUNC) &ffi_env_bind_list, 3}, {"ffi_env_binding_types", (DL_FUNC) &r_env_binding_types, 2}, - {"ffi_env_browse", (DL_FUNC) &ffi_env_browse, 2}, {"ffi_env_clone", (DL_FUNC) &r_env_clone, 2}, {"ffi_env_coalesce", (DL_FUNC) &ffi_env_coalesce, 2}, {"ffi_env_frame", (DL_FUNC) &ffi_env_frame, 1}, @@ -83,7 +82,6 @@ static const R_CallMethodDef r_callables[] = { {"ffi_env_has", (DL_FUNC) &ffi_env_has, 3}, {"ffi_env_hash_table", (DL_FUNC) &ffi_env_hash_table, 1}, {"ffi_env_inherits", (DL_FUNC) &ffi_env_inherits, 2}, - {"ffi_env_is_browsed", (DL_FUNC) &ffi_env_is_browsed, 1}, {"ffi_env_poke", (DL_FUNC) &ffi_env_poke, 5}, {"ffi_env_poke_parent", (DL_FUNC) &ffi_env_poke_parent, 2}, {"ffi_env_unbind", (DL_FUNC) &ffi_env_unbind, 3}, diff --git a/tests/testthat/test-env.R b/tests/testthat/test-env.R index f1e38a24d..db390e3c0 100644 --- a/tests/testthat/test-env.R +++ b/tests/testthat/test-env.R @@ -519,19 +519,6 @@ test_that("get_env() returns the base namespace for primitive functions (r-lib/d expect_identical(get_env(is.null), ns_env("base")) }) -test_that("can browse environments", { - env <- env() - expect_false(env_is_browsed(env)) - - old <- env_browse(env) - expect_false(old) - expect_true(env_is_browsed(env)) - - old <- env_browse(env, FALSE) - expect_true(old) - expect_false(env_is_browsed(env)) -}) - test_that("env_has() doesn't force active bindings (#1292)", { e <- env() env_bind_active(e, active = function() abort("forced"))