Skip to content
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

os.utime raises exceptions without a filename. #109033

Closed
rpigott opened this issue Sep 6, 2023 · 1 comment
Closed

os.utime raises exceptions without a filename. #109033

rpigott opened this issue Sep 6, 2023 · 1 comment
Labels
type-bug An unexpected behavior, bug, or error

Comments

@rpigott
Copy link
Contributor

rpigott commented Sep 6, 2023

Bug report

Bug description:

The builtin os.utime option raises exceptions without a filename. E.g. on Linux:

import os
try:
    os.utime('/root', None)
except PermissionError as e:
    print(e.filename) # None

The source actually provides a justification for this omission:

 /* Avoid putting the file name into the error here,
     as that may confuse the user into believing that
     something is wrong with the file, when it also
     could be the time stamp that gives a problem. */

which really is no justification at all.

Uncaught exceptions are not usually considered a replacement for user-facing error messages, so omitting the filename here is at best a guidance to the programmer, but this approach unnecessarily removes context that could be helpful in crafting a useful error message. On Linux at least, I don't even think that the exception traceback has the potential for confusion raised in this comment — EPERM could quite clearly mean that my user lacks the requisite permission to modify the file in whatever relevant way, including changing the timestamps.

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Linked PRs

@rpigott rpigott added the type-bug An unexpected behavior, bug, or error label Sep 6, 2023
rpigott added a commit to rpigott/cpython that referenced this issue Sep 6, 2023
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.
rpigott added a commit to rpigott/cpython that referenced this issue Sep 6, 2023
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.
rpigott added a commit to rpigott/cpython that referenced this issue Sep 7, 2023
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.
rpigott added a commit to rpigott/cpython that referenced this issue Sep 8, 2023
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.
rpigott added a commit to rpigott/cpython that referenced this issue Sep 9, 2023
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.
rpigott added a commit to rpigott/cpython that referenced this issue Sep 19, 2023
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.
rpigott added a commit to rpigott/cpython that referenced this issue Sep 19, 2023
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.
vstinner pushed a commit that referenced this issue Sep 19, 2023
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.
@vstinner
Copy link
Member

Implemented in ddf2e95

csm10495 pushed a commit to csm10495/cpython that referenced this issue Sep 28, 2023
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.
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants