[issue47198] os.stat on windows doesn't take an open file even though os.stat in os.supports_fd

2022-04-01 Thread Joe Cool
New submission from Joe Cool : os.stat on windows doesn't take an open file even though os.stat in os.supports_fd >>> fd = open('tmp.tmp', 'w') >>> fd <_io.TextIOWrapper name='tmp.tmp' mode='w' encoding='cp1252'> >>> os.stat(fd) Traceback (most recent call last): File "", line 1, in TypeErr

[issue47198] os.stat on windows doesn't take an open file even though os.stat in os.supports_fd

2022-04-01 Thread Eryk Sun
Eryk Sun added the comment: You're mistaken about what `fd` is. It's a TextIOWrapper, which wraps a BufferedWriter, which buffers a FileIO raw file object, which accesses the open file number fd.fileno(). For example: >>> f = open('tmp.tmp','w') >>> os.stat(f.fileno()).st_size 0