Skip to content

Commit

Permalink
fix writeObject.environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Chirico committed Apr 29, 2020
1 parent 950da2c commit 8af440d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions R/pkg/R/serialize.R
Expand Up @@ -161,8 +161,13 @@ writeObject.environment <- function(object, con, writeType = TRUE) {
# vector of names for environment doesn't include the array marker,
# so manually write the character marker & then the names object itself
writeType("", con)
writeObject(envObj, con, writeType = FALSE)
writeObject(mget(envObj, object), con, writeType = FALSE)
# force array-like writing (even for singleton object)
writeObject(length(envObj), con, writeType = FALSE)
for (nm in envObj) writeObject(nm, con, writeType = FALSE)
# also force list writing (even for array-able env contents)
vals <- mget(envObj, object)
writeObject(length(vals), con, writeType = FALSE)
for (val in vals) writeObject(val, con, writeType = TRUE)
}
}

Expand Down

0 comments on commit 8af440d

Please sign in to comment.