Skip to content

Commit 6f102ce

Browse files
committed
Deprecate env_browse() and env_is_browsed()
Closes #1727
1 parent 5634e96 commit 6f102ce

File tree

7 files changed

+13
-42
lines changed

7 files changed

+13
-42
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Suggests:
4444
Enhances:
4545
winch
4646
Encoding: UTF-8
47-
RoxygenNote: 7.3.1
47+
RoxygenNote: 7.3.2
4848
Roxygen: list(markdown = TRUE)
4949
URL: https://rlang.r-lib.org, https://github.com/r-lib/rlang
5050
BugReports: https://github.com/r-lib/rlang/issues

NEWS.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# rlang (development version)
22

3+
* `env_browse()` and `env_is_browsed()` are now defunct as they require an API
4+
that is no longer available to packages (#1727).
5+
36
* `env_unlock()` is now defunct because recent versions of R no long
4-
make it possible to unlock an environment. Make sure to use an up-to-date
5-
version of pkgload (>= 1.4.0) following this change.
7+
make it possible to unlock an environment (#1705). Make sure to use an
8+
up-to-date version of pkgload (>= 1.4.0) following this change.
69

710

811
# rlang 1.1.4

R/env.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,8 @@ env_is_locked <- function(env) {
566566
env_unlock <- function(env) {
567567
msg <- "`env_unlock()` is defunct as of rlang 1.1.5"
568568

569-
old_pkgload_running <-
570-
"pkgload" %in% loadedNamespaces() &&
569+
old_pkgload_running <-
570+
"pkgload" %in% loadedNamespaces() &&
571571
some(sys.frames(), function(env) identical(topenv(env), ns_env("pkgload"))) &&
572572
utils::packageVersion("pkgload") <= "1.3.4"
573573

@@ -754,6 +754,8 @@ str.rlang_envs <- function(object, ...) {
754754
#'
755755
#' @description
756756
#'
757+
#' `r lifecycle::badge("defunct")`
758+
#'
757759
#' * `env_browse(env)` is equivalent to evaluating `browser()` in
758760
#' `env`. It persistently sets the environment for step-debugging.
759761
#' Supply `value = FALSE` to disable browsing.
@@ -767,12 +769,12 @@ str.rlang_envs <- function(object, ...) {
767769
#' `env_is_browsed()` (a logical), invisibly.
768770
#' @export
769771
env_browse <- function(env, value = TRUE) {
770-
invisible(.Call(ffi_env_browse, env, value))
772+
abort("`env_browse()` is defunct as of rlang 1.2.0 because R no longer supports it")
771773
}
772774
#' @rdname env_browse
773775
#' @export
774776
env_is_browsed <- function(env) {
775-
.Call(ffi_env_is_browsed, env)
777+
abort("`env_is_browsed()` is defunct as of rlang 1.2.0 because R no longer supports it")
776778
}
777779

778780
#' Is frame environment user facing?

man/env_browse.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/internal/exported.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -511,26 +511,6 @@ r_obj* ffi_env_bind_list(r_obj* env, r_obj* names, r_obj* data) {
511511
return r_null;
512512
}
513513

514-
r_obj* ffi_env_browse(r_obj* env, r_obj* value) {
515-
if (r_typeof(env) != R_TYPE_environment) {
516-
r_abort("`env` must be an environment.");
517-
}
518-
if (!r_is_bool(value)) {
519-
r_abort("`value` must be a single logical value.");
520-
}
521-
522-
r_obj* old = r_lgl(RDEBUG(env));
523-
SET_RDEBUG(env, r_lgl_get(value, 0));
524-
return old;
525-
}
526-
527-
r_obj* ffi_env_is_browsed(r_obj* env) {
528-
if (r_typeof(env) != R_TYPE_environment) {
529-
r_abort("`env` must be an environment.");
530-
}
531-
return r_lgl(RDEBUG(env));
532-
}
533-
534514
r_obj* ffi_ns_registry_env(void) {
535515
return R_NamespaceRegistry;
536516
}

src/internal/init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ static const R_CallMethodDef r_callables[] = {
7474
{"ffi_env_bind", (DL_FUNC) &ffi_env_bind, 5},
7575
{"ffi_env_bind_list", (DL_FUNC) &ffi_env_bind_list, 3},
7676
{"ffi_env_binding_types", (DL_FUNC) &r_env_binding_types, 2},
77-
{"ffi_env_browse", (DL_FUNC) &ffi_env_browse, 2},
7877
{"ffi_env_clone", (DL_FUNC) &r_env_clone, 2},
7978
{"ffi_env_coalesce", (DL_FUNC) &ffi_env_coalesce, 2},
8079
{"ffi_env_frame", (DL_FUNC) &ffi_env_frame, 1},
@@ -83,7 +82,6 @@ static const R_CallMethodDef r_callables[] = {
8382
{"ffi_env_has", (DL_FUNC) &ffi_env_has, 3},
8483
{"ffi_env_hash_table", (DL_FUNC) &ffi_env_hash_table, 1},
8584
{"ffi_env_inherits", (DL_FUNC) &ffi_env_inherits, 2},
86-
{"ffi_env_is_browsed", (DL_FUNC) &ffi_env_is_browsed, 1},
8785
{"ffi_env_poke", (DL_FUNC) &ffi_env_poke, 5},
8886
{"ffi_env_poke_parent", (DL_FUNC) &ffi_env_poke_parent, 2},
8987
{"ffi_env_unbind", (DL_FUNC) &ffi_env_unbind, 3},

tests/testthat/test-env.R

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -519,19 +519,6 @@ test_that("get_env() returns the base namespace for primitive functions (r-lib/d
519519
expect_identical(get_env(is.null), ns_env("base"))
520520
})
521521

522-
test_that("can browse environments", {
523-
env <- env()
524-
expect_false(env_is_browsed(env))
525-
526-
old <- env_browse(env)
527-
expect_false(old)
528-
expect_true(env_is_browsed(env))
529-
530-
old <- env_browse(env, FALSE)
531-
expect_true(old)
532-
expect_false(env_is_browsed(env))
533-
})
534-
535522
test_that("env_has() doesn't force active bindings (#1292)", {
536523
e <- env()
537524
env_bind_active(e, active = function() abort("forced"))

0 commit comments

Comments
 (0)