Skip to content

Commit 9f1c128

Browse files
committed
Use ns_registry_env() on older R versions
1 parent c46fbde commit 9f1c128

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

R/namespace-env.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,12 @@ register_namespace <- function(name = NULL, env = NULL) {
234234
}
235235

236236
# Add the environment to the registry
237-
eval(call2(".Internal", call2("registerNamespace", name, env)))
237+
if (getRversion() >= "4.6.0") {
238+
eval(call2(".Internal", call2("registerNamespace", name, env)))
239+
} else {
240+
nsr <- ns_registry_env()
241+
nsr[[name]] <- env
242+
}
238243

239244
env
240245
}
@@ -263,7 +268,11 @@ unregister_namespace <- function(name = NULL) {
263268
env_get_list(ns, names(active_bindings)[!active_bindings])
264269

265270
# Remove the item from the registry
266-
eval(call2(".Internal", call2("unregisterNamespace", name)))
271+
if (getRversion() >= "4.6.0") {
272+
eval(call2(".Internal", call2("unregisterNamespace", name)))
273+
} else {
274+
env_unbind(ns_registry_env(), name)
275+
}
267276
invisible()
268277
}
269278

0 commit comments

Comments
 (0)