Are there any objects for which it is impossible to create a deep copy?

I get an error while executing the following line:

img = copy.deepcopy(img_file_obj)

img_file_obj has the following type:

<class 'werkzeug.datastructures.FileStorage'>

Can't create a deep copy of a file storage object?

ADDED

I probably need to explain why I'm trying to create a copy of the file storage object. At the end of my code, I execute:

img_obj.save(fname)

But before that I check how big the file is. I do it as follows:

img_obj.seek(0, os.SEEK_END)
size = img.tell()

The problem is that checking the size "destroys" the file. If I check the file size and then save it, I will get an empty file on disk. That is why I wanted to create a copy of the object file, check the size of the copy and, if the size is acceptable, save the original file object on disk.

+4
3

, ?

.

, __deepcopy__ ( copyreg), , , .

, __deepcopy__, (), .

( __deepcopy__ ), , .

, -. copy :

, , , , , , , , .

, , , ( , ? ? ?), , .

, Werkzeug FileStorage , Python - , , -, .

+3

, , . :

, __copy__() __deepcopy__().

, undeepcopyable, .

, - - , . - . , ; , .. , , . - , , ; , .

+2

copy :

, , , , , , , , .

Since it is a werkzeug.datastructures.FileStorage "thin shell over incoming files" , I would say that it is considered a "similar type" to a filefor the text indicated above.

+1
source

All Articles