-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-109033: Return filename with os.utime errors #109034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
57bd8c6
to
9f064ec
Compare
Added a NEWS entry. |
e49b5f1
to
41c567c
Compare
Windows fails apparently unrelated. Went away after rebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test in Lib/test/test_os.py, in UtimeTests.
Call os.utime() on a non-existant filename, and then make sure that exc.filename is equal to the requested filename.
Something like:
now = time.time()
with self.assertRaises(OSError) as cm
os.utime(filename, (now, now), follow_symlinks=False)
self.assertEqual(cm.exception.filename, filename)
41c567c
to
4141efd
Compare
The filename was previously intentionally omitted from exception becuase "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.
4141efd
to
61977d1
Compare
|
I think that it makes sense to include the filename in the OSError, since it's an obvious and mandatory argument of os.utime(). I merged your PR. Thanks for the added test. It's a new feature, it should not backported to 3.11 and 3.12 branches.
Oh ok. It's not really needed by the test, it's fine to skip it. |
|
|
|
|
|
|
|
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.
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.
The filename was previously intentionally omitted from exception becuase "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.