[New-bugs-announce] [issue37436] os.path.isfile() with big number cause OverflowError: fd is greater than maximum

Zufu Liu report at bugs.python.org
Thu Jun 27 21:53:43 EDT 2019


New submission from Zufu Liu <zufuliu at 163.com>:

I think it's should be TypeError as Python 2.7.

The doc https://docs.python.org/3/library/os.path.html
doesn't says it accept file descriptor.


Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os.path
>>> os.path.isfile(123)
False
>>> os.path.isfile(2**32)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Dev\Python3\lib\genericpath.py", line 30, in isfile
    st = os.stat(path)
OverflowError: fd is greater than maximum
>>>

Python 3.8.0b1 (tags/v3.8.0b1:3b5deb0116, Jun  4 2019, 19:52:55) [MSC v.1916 64 bit (AMD64)] on win32
>>> import os.path
>>> os.path.isfile(123)
False
>>> os.path.isfile(2**32)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\obj\Windows-Release\38amd64_Release\msi_python\zip_amd64\genericpath.py", line 30, in isfile
OverflowError: fd is greater than maximum
>>>

Python 2.7.16 (v2.7.16:413a49145e, Mar  4 2019, 01:37:19) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os.path
>>> os.path.isfile(123)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Dev\Python\lib\genericpath.py", line 37, in isfile
    st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, int found
>>>

----------
components: Library (Lib), Windows
messages: 346792
nosy: paul.moore, steve.dower, tim.golden, zach.ware, zufuliu
priority: normal
severity: normal
status: open
title: os.path.isfile() with big number cause OverflowError: fd is greater than maximum
type: behavior
versions: Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37436>
_______________________________________


More information about the New-bugs-announce mailing list