Is python not fully implemented on Windows?

  Kiến thức lập trình

At least on my system (Windows 11 Enterprise, Python 3.12.2), using, 'wb') to write a compressed file creates an empty .gz file, despite reporting having written data.

Minimal example:

data = b'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
written ='D:\tmp\try1.gz', 'wb').write(data)
compressed_written = os.stat('D:\tmp\try1.gz').st_size
print("theoretically written", written, "B, compressed size is", compressed_written, "B")

Which prints out (on my system): theoretically written 445 B, compressed size is 0 B

Is this expected behaviour due to it not being supported on Windows, or is this a bug? (and if so, where should I report it?)

P.S.: Same thing occurs when using a with statement block.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website