[issue43039] tempfile.TemporaryDirectory() name string is incorrect
Eric Osborne
report at bugs.python.org
Wed Jan 27 08:06:25 EST 2021
New submission from Eric Osborne <eosborne at vapor.io>:
When I create a temporary directory, the name doesn't come back in a way the application expects it. I ran into this using gitPython and I'm not entirely clear whether it's a tmpfile issue or a gitpython issue, but I think it's tempfile.
Repro:
In [12]: td = tempfile.TemporaryDirectory()
In [13]: td.name
Out[13]: '/var/folders/kd/bjhw84ss2x734frx98qh1mw40000gn/T/tmpgralfh9m'
In [14]: str(td)
Out[14]: "<TemporaryDirectory '/var/folders/kd/bjhw84ss2x734frx98qh1mw40000gn/T/tmpgralfh9m'>"
The problem with this is that gitPython takes a temporary directory as an argument and effectively does a mkdir(str(td)), which creates a weird directory in /var/tmp:
eosborne at eosborne-salt-master:/tmp$ ls -alhd *Temp*
drwxrwxr-x 3 eosborne eosborne 4.0K Jan 27 12:42 '<TemporaryDirectory '\'''
I believe that str(td) should return just the directory name and that repr(td) can return the extra bit of text with "<TemporaryDirectory ..>" but that's just my two cents.
I have thrown this issue up on the gitPython list too: https://github.com/gitpython-developers/GitPython/issues/1115
----------
components: Library (Lib)
messages: 385768
nosy: eosborne
priority: normal
severity: normal
status: open
title: tempfile.TemporaryDirectory() name string is incorrect
versions: Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43039>
_______________________________________
More information about the Python-bugs-list
mailing list