[英]Read python pickle with scala
I inherited a database with values stored as Python pickled objects. 我继承了一个数据库,其值存储为Python pickle对象。 Is there a way to unpickle these values in Scala (without calling Python internally) ?
有没有办法在Scala中取消这些值(不在内部调用Python)?
In general, you'd need to call python internally, because pickle allows classes to run arbitrary code on unpickling. 通常,你需要在内部调用python,因为pickle允许类在unpickling上运行任意代码。 (Do a search for "python pickle security" and you'll find a lot of interesting discussions about why this means you shouldn't unpickle from untrusted sources.)
(搜索“python pickle security”,你会发现很多有趣的讨论 ,为什么这意味着你不应该从不受信任的来源中解开。)
I suspect it could be done for more common cases, though, if there's nothing particularly unusual in your pickled data. 我怀疑它可以用于更常见的情况,但是,如果你的腌制数据中没有什么特别不寻常的话。 This simliar question has an answer suggesting a Java library called Pyrolite .
这个简短的问题有一个答案暗示了一个名为Pyrolite的Java库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.