mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-109033: Return filename with os.utime errors (#109034)
The filename was previously intentionally omitted from exception because "it might confuse the user". Uncaught exceptions are not generally a replacement for user-facing error messages, so obscuring this information only has the effect of making the programmer's life more difficult.
This commit is contained in:
parent
fd7e08a6f3
commit
ddf2e953c2
3 changed files with 11 additions and 7 deletions
|
@ -913,6 +913,13 @@ class UtimeTests(unittest.TestCase):
|
|||
os.utime(self.fname, None)
|
||||
self._test_utime_current(set_time)
|
||||
|
||||
def test_utime_nonexistent(self):
|
||||
now = time.time()
|
||||
filename = 'nonexistent'
|
||||
with self.assertRaises(FileNotFoundError) as cm:
|
||||
os.utime(filename, (now, now))
|
||||
self.assertEqual(cm.exception.filename, filename)
|
||||
|
||||
def get_file_system(self, path):
|
||||
if sys.platform == 'win32':
|
||||
root = os.path.splitdrive(os.path.abspath(path))[0] + '\\'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue