简体   繁体   English

Python:为什么无法腌制File对象?

[英]python: why a File object cannot be pickled?

I am trying to understand why sending a django InMemoryUploadedFile object cannot be pickled when sending it as an argument of a celery task, Can't pickle <type 'cStringIO.StringO'>: attribute lookup cStringIO.StringO failed . 我试图理解为什么将django InMemoryUploadedFile对象作为芹菜任务的参数发送时无法腌制, Can't pickle <type 'cStringIO.StringO'>: attribute lookup cStringIO.StringO failed So i tried out the File object, doesn't work as well, but a StringIO would work. 因此,我尝试了File对象,但效果不佳,但是StringIO可以工作。

Need some dummies' guidance in understanding the difference between the 3. 在理解这三者之间的区别时需要一些假人的指导。

thanks! 谢谢!

Python does not allow pickling of some functions either, because of security problems if it were to be allowed. Python也不允许对某些功能进行酸洗,因为如果允许的话,由于安全性问题。 (It depends - there are ways to pickle some functions by reference) (这取决于-有一些方法可以通过引用来腌制某些功能)

Pickling file objects has been requested in the features threads of python many times, and the best reasoning is because it opens up additional hack vectors into the security processes of python, by allowing run-time injections of potentially malicious events. 在python的功能线程中已多次请求对文件进行酸洗,并且最好的理由是,通过允许运行时注入潜在的恶意事件,它为python的安全进程打开了额外的hack向量。

It would be very convenient to have in a number of ways, but it appears to be a security restriction. 以多种方式进行操作将非常方便,但这似乎是一种安全限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM