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

posix_access swallows all errors #54967

Open
birkenfeld opened this issue Dec 22, 2010 · 3 comments
Open

posix_access swallows all errors #54967

birkenfeld opened this issue Dec 22, 2010 · 3 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@birkenfeld
Copy link
Member

BPO 10758
Nosy @loewis, @birkenfeld, @pitrou

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2010-12-22.12:45:08.599>
labels = ['type-feature', 'library']
title = 'posix_access swallows all errors'
updated_at = <Date 2010-12-22.20:16:54.361>
user = 'https://github.com/birkenfeld'

bugs.python.org fields:

activity = <Date 2010-12-22.20:16:54.361>
actor = 'loewis'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2010-12-22.12:45:08.599>
creator = 'georg.brandl'
dependencies = []
files = []
hgrepos = []
issue_num = 10758
keywords = []
message_count = 3.0
messages = ['124500', '124517', '124520']
nosy_count = 4.0
nosy_names = ['loewis', 'georg.brandl', 'pitrou', 'rosslagerwall']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue10758'
versions = ['Python 3.3']

@birkenfeld
Copy link
Member Author

access(2) can return errnos that correspond to input errors or general system faults, such as EINVAL, EIO or ENOMEM. In this case, an exception should be raised instead of returning False.

It is probably best to whitelist those errnos that indicate missing access -- it needs to be discussed whether that is just EACCES, or also e.g. ENOENT.

@birkenfeld birkenfeld added type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir labels Dec 22, 2010
@pitrou
Copy link
Member

pitrou commented Dec 22, 2010

The list of errnos indicating missing access seems open-ended.
Things such as:

[ENAMETOOLONG]
The length of a component of a pathname is longer than {NAME_MAX}.
[ENOENT]
A component of path does not name an existing file or path is an empty string.
[ENOTDIR]
A component of the path prefix is not a directory, or the path argument contains at least one non- <slash> character and ends with one or more trailing <slash> characters and the last pathname component names an existing file that is neither a directory nor a symbolic link to a directory.
[EROFS]
Write access is requested for a file on a read-only file system.

... may be considered missing access.

@pitrou pitrou added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Dec 22, 2010
@loewis
Copy link
Mannequin

loewis mannequin commented Dec 22, 2010

I don't think we can change this for the maintenance branches. The code behaves according to the documentation:

access(path, mode) -> True if granted, False otherwise

"False otherwise" is really meant that way: otherwise. The specific condition is indeed not communicated. However, applications are entitled to not seeing exceptions come out of this function.

I would be in favor of changing this in the long term, but then raise exceptions in all cases. Alternatively, have it produce falsish values that encapsulate the error code.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants