Skip to content

[python-crontab] UserSpool.get_owner() can return None - #16869

Open
ArthDubey1011 wants to merge 1 commit into
python:mainfrom
ArthDubey1011:none-crontab
Open

ArthDubey1011 wants to merge 1 commit into
python:mainfrom
ArthDubey1011:none-crontab

Conversation

@ArthDubey1011

@ArthDubey1011 ArthDubey1011 commented Nov 19, 2026 •

Copy link
Copy Markdown

UserSpool.get_owner() returns None when the file's owner UID has no entry in the password database, since it catches the KeyError from pwd.getpwuid() with a bare return (python-crontab 3.4):

def get_owner(self, path):

    """Returns user file at path"""

    if not getpwuid:

        raise OSError("This functionality is not available on Windows")

    try:

        return getpwuid(stat(path).st_uid).pw_name

    except KeyError:

        return

This happens, for example, for a spool file owned by a UID that was deleted, or one that isn't in the container's /etc/passwd.

AI assistance: Claude Code (Claude Opus 5.5) found this by comparing the stubs with the runtime source, ran the check above and made the edit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant