Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gergness committed Feb 22, 2024
1 parent 84deb87 commit 647f064
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# rlang (development version)

* Fix for reticulate errors (#1664)

* `last_trace()` hyperlinks now use the modern `x-r-run` format (#1678).


Expand Down
3 changes: 2 additions & 1 deletion src/rlang/cnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ void r_interrupt(void) {

enum r_cnd_type r_cnd_type(r_obj* cnd) {
r_obj* classes = r_class(cnd);
if (r_typeof(cnd) != R_TYPE_list ||
if (
(r_typeof(cnd) != R_TYPE_list && r_typeof(cnd) != R_TYPE_environment) ||
r_typeof(classes) != R_TYPE_character) {
goto error;
}
Expand Down
7 changes: 5 additions & 2 deletions tests/testthat/test-cnd.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ test_that("calls are consistently displayed on rethrow (#1240)", {
expr = force(expr),
error = function(cnd) {
rlang::abort(
message = "Problem while executing step.",
call = call(step_name),
message = "Problem while executing step.",
call = call(step_name),
parent = cnd
)
}
Expand Down Expand Up @@ -252,6 +252,9 @@ test_that("cnd_type() detects condition type", {
expect_identical(cnd_type(warning_cnd()), "warning")
expect_identical(cnd_type(error_cnd()), "error")
expect_identical(cnd_type(catch_cnd(interrupt())), "interrupt")
# reticulate stores error conditions as environments (#1664)
env_cnd <- structure(env(), class = c("error", "condition"))
expect_identical(cnd_type(env_cnd), "error")
})

test_that("bare conditions must be subclassed", {
Expand Down

0 comments on commit 647f064

Please sign in to comment.