Repository navigation
[HWORKS-3320] Fix import on Python 3.13 when the UID has no passwd entry, release 0.2.4 - #8
Merged
Merged
Conversation
…r entry Fixes aio-libs#1053. As of Python 3.13, getpass.getuser() raises OSError instead of KeyError when there's no entry in the OS user database for the current uid (e.g. an arbitrary uid in a container). The module-level fallback only caught KeyError, so importing aiomysql crashed outright in that environment. Catch OSError too, matching the fix PyMySQL applied for the same underlying getpass change (referenced in the issue). (cherry picked from commit 09f2110)
The test's cleanup reloaded aiomysql.connection before monkeypatch undid the getpass.getuser patch, so the reload still observed the broken getuser and left DEFAULT_USER stuck at "unknown" afterwards. The reload also left aiomysql.Connection/aiomysql.connect pointing at the pre-reload objects while aiomysql.connection.Connection/connect were replaced, breaking identity checks for any test that runs after this one. Undo the monkeypatch before reloading, and reload the parent aiomysql package too so its re-exported names match the reloaded submodule again. (cherry picked from commit 6e8eb18)
…ading modules (cherry picked from commit f242454)
https://hopsworks.atlassian.net/browse/HWORKS-3320 The getpass.getuser() OSError fallback needs a release for hopsworks-api to pin to. Without it, importing aiomysql (and so hsfs) fails on Python 3.13 under a UID with no passwd entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KaDhXWqsBJ2QcoePWyrb62
manu-sj
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://hopsworks.atlassian.net/browse/HWORKS-3320
On Python 3.13,
import aiomysql(and soimport hsfs) fails when the process runs as a UID with no/etc/passwdentry and neitherUSERnorLOGNAMEis set, which is the normal case for arbitrary UIDs on OpenShift:Since 3.13,
getpass.getuser()raisesOSErrorwhere it used to raiseKeyError, andconnection.pycatches onlyKeyErroraround the import-timeDEFAULT_USER = getpass.getuser(). PyMySQL catches both.Changes
getpass.getuseron Python 3.13+ aio-libs/aiomysql#1053), cherry-picked with-xand with the original messages and authors:except (KeyError, OSError)inaiomysql/connection.py, plus a regression test that imports the module in a fresh interpreter withgetpass.getuserraising each exception. No upstream release contains it yet; 0.3.2 is the latest.setup.cfg: version 0.2.3 -> 0.2.4.Testing
hopsworks_aiomysql-0.2.4-py3-none-any.whl) and installed into the Python 3.13 python-feature-pipeline image from logicalclocks/docker-images#1078, run as--user 1000670000:0withUSER/LOGNAMEunset:import hsfsworks andDEFAULT_USERis"unknown". With 0.2.3 the same command fails as above.Release
This targets
0.2.4, a new release branch cut from0.2.3(same commit,022290e). After merge, run thehopsworks-aiomysqlJenkins job, which builds*/0.2.*branches and uploads to PyPI. Then bumphopsworks_aiomysql[sa]==0.2.3to0.2.4in hopsworks-apipython/pyproject.toml.Replaces #7, which targeted
master.🤖 Generated with Claude Code
https://claude.ai/code/session_01KaDhXWqsBJ2QcoePWyrb62