New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems serializing R POSIXlt objects #47
Comments
That may be more a known issue with You could address it on your side by focusing
Also:
|
Sorry for not following up sooner @eddelbuettel , that's fair. My main motivation was encountering this issue before in #37 as well. I doubt these 2 are isolated cases. I do agree it's a big change. Would a more narrow condition, like checking if unclassing the list changes the value of the list be more appropriate? I do agree there are workarounds, but it seems odd for this library not to handle base data types |
Well, one step at a time. #37 is closed, and if there was an issue, wasn't it with As for falling over
That would be a bit more surgical. And should overcome the issue while not changing things for everybody else. |
Okay I'm happy to make that change, I've updated the PR now. The issue with #37 was that calling |
That looks better, and is more minimal. |
I think the original proposal to unconditionally unclass lists to get the expected obj <- as.POSIXlt(Sys.time())
protolite::unserialize_pb(protolite::serialize_pb(obj, connection=NULL)) |
I still find it a little broad. But the dispatching from msg <- switch(sm,
"character" = rexp_string(obj),
"raw" = rexp_raw(obj),
"double" = rexp_double(obj),
"complex" = rexp_complex(obj),
"integer" = rexp_integer(obj),
"list" = rexp_list(obj),
"logical" = rexp_logical(obj),
"NULL" = rexp_null(),
return(rexp_native(obj))
); via |
#48 is merged so closing. Thanks for the PR! |
I ran into an issue recently when using rprotobuf to serialize then deserialize a POSIXlt object:
yields the following error:
what's happening is that the POSIXlt object is represented as a list of attributes in R e.g. (hours, min, sec...) but when iterated over using lapply it appears only to be a list of length 1. Only by unclassing the object do we see its true representation:
this somewhat related to #37 which had a similar issue where the list access had special handling for a particular class of object.
I propose that prior to serializing lists in the package we unclass the object beforehand
The text was updated successfully, but these errors were encountered: