Victor Stinner wrote: > Le mercredi 04 mai 2011 à 15:40 -0700, Ethan Furman a écrit : >> Victor Stinner wrote: >>> Le mardi 03 mai 2011 à 16:22 +0200, Nadeem Vawda a écrit : >>>> On Tue, May 3, 2011 at 3:19 PM, victor.stinner >>>> <python-checkins at python.org> wrote: >>>>> >>>>> + int_max = 0x7FFFFFFF >>>>> >>>>> + with open(TESTFN, "wb+") as f: >>>>> + f.seek(self.int_max-4) >>>>> + f.write("asdf") >>>>> + f.flush() >>>> >>>> 0x7FFFFFFF is (2G-1) bytes. For a 2GB buffer, int_max should be >>>> 0x80000000. However, if you make this change, crc32() and adler32() >>>> raise OverflowErrors (see changeset a0681e7a6ded). >>> >>> I don't want to check OverflowError: the test is supposed to compute the >>> checksum of a buffer of 0x7FFFFFFF bytes >> >> The comment says 'check that inputs of 2 GB are handled correctly' but >> the file created is 1 byte short of 2Gb. Is the test wrong, or just >> wrongly commented? Or am I not understanding? > > If you write a byte after 2 GB of zeros, the file size is 2 GB+the few > bytes. This trick is to create quickly a large file: some OSes support > sparse files, zeros are not written on disk. But on Mac OS X and > Windows, you really write 2 GB+some bytes. True, but that's not what's happening -- four bytes are being written at int_max - 4, and int_max is one less that 2GB; hence the resulting file is one less than 2GB. ~Ethan~
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4