Skip to content

Commit f4feb15

Browse files
author
smeyer
committed
test fixInNamespace()
git-svn-id: https://svn.r-project.org/R/trunk@88424 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent d578dd1 commit f4feb15

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/library/utils/R/objects.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ function(x, value, ns, pos = -1, envir = as.environment(pos))
443443
ns <- asNamespace(substring(nm, 9L))
444444
} else ns <- asNamespace(ns)
445445
ns_name <- getNamespaceName(ns)
446-
if (nf > 1L) {
446+
if (nf > 1L && !identical(sys.function(1), fixInNamespace)) {
447447
if(ns_name %in% tools:::.get_standard_package_names()$base)
448448
stop("locked binding of ", sQuote(x), " cannot be changed",
449449
domain = NA)

tests/reg-tests-1e.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,8 +2040,9 @@ omethod <- tools:::toRd.default
20402040
assignInNamespace("toRd.default", `body<-`(omethod, value = ""), "tools")
20412041
## R <= 4.5.1 gave Error: object 'toRd' of mode 'function' was not found
20422042
assertValueIs("") # failed for tools::toRd(1): S3 table was not updated
2043-
## now restore the original definition:
2044-
assignInNamespace("toRd.default", omethod, "tools")
2043+
## now restore the original definition, testing fixInNamespace():
2044+
fixInNamespace("toRd.default", "tools", editor = function (...) omethod)
2045+
## failed in R <= 4.5.1
20452046
assertValueIs("1")
20462047

20472048

0 commit comments

Comments
 (0)