Skip to content

Changed on python 3.13 #157

Description

@shsailaubay

Summary

ClientInfo class call getpass.getuser function on init dundermethod and catch KeyError exception. This is work for python <=3.12, but on python 3.13 version exception type raising from getpass.getuser function has been changed to OSError.

When using asynch with python >= 3.12 version we have uncaught exception.

Traceback

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/getpass.py", line 173, in getuser
    return pwd.getpwuid(os.getuid())[0]
           ~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'getpwuid(): uid not found: 10000'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/app/lib/python3.13/site-packages/asynch/cursors.py", line 75, in execute
    response = await execute(query, args=args, with_column_types=True, **execute_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/app/lib/python3.13/site-packages/asynch/proto/connection.py", line 638, in execute
    async with ExecuteContext(self, query, settings):
               ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/app/lib/python3.13/site-packages/asynch/proto/context.py", line 60, in __aexit__
    raise exc_val
  File "/opt/app/lib/python3.13/site-packages/asynch/proto/connection.py", line 653, in execute
    rv = await self.process_ordinary_query(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/opt/app/lib/python3.13/site-packages/asynch/proto/connection.py", line 778, in process_ordinary_query
    await self.send_query(query, query_id=query_id)
  File "/opt/app/lib/python3.13/site-packages/asynch/proto/connection.py", line 520, in send_query
    client_info = ClientInfo(self.client_name, self.writer, self.context)
  File "/opt/app/lib/python3.13/site-packages/asynch/proto/cs.py", line 68, in __init__
    self.os_user = getpass.getuser()
                   ~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/getpass.py", line 175, in getuser
    raise OSError('No username set in the environment') from e
OSError: No username set in the environment 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions