[New-bugs-announce] [issue45192] The tempfile._infer_return_type function cannot infer the type of os.PathLike objects.

Kyungmin Lee report at bugs.python.org
Tue Sep 14 01:44:04 EDT 2021


New submission from Kyungmin Lee <rekyungmin at gmail.com>:

The tempfile module has been updated to accept an object implementing os.PathLike protocol for path-related parameters as of Python 3.6 (e.g. dir parameter). An os.PathLike object represents a filesystem path as a str or bytes object (i.e. def __fspath__(self) -> Union[str, bytes]:). However, if an object implementing os.PathLike[bytes] is passed as a dir argument, a TypeError is raised. This bug occurs because the tempfile._infer_return_type function considers all objects other than bytes as str type.

----------
components: Library (Lib)
messages: 401754
nosy: rekyungmin
priority: normal
severity: normal
status: open
title: The tempfile._infer_return_type function cannot infer the type of os.PathLike objects.
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

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


More information about the New-bugs-announce mailing list