Skip to content

Client.get_self() crashes with AttributeError: 'http' object has no attribute 'session' #29

@ulidtko

Description

@ulidtko

Summary

Probably uses obsolete version of aiohttp

Reproduction Steps

python -m venv reprovenv
source reprovenv/bin/activate.fish
pip install github
./test.py

Minimal Reproducible Code

#!/usr/bin/env python

import asyncio
import github

GITHUB_TOKEN = "gho_...................................."
GITHUB_USER = 'ulidtko'

async def main():
    gh = github.Client(username=GITHUB_USER, token=GITHUB_TOKEN)
    user = await gh.get_self()
    print(user)

asyncio.run(main())

Expected Results

A user record printed

Actual Results

Traceback (most recent call last):
  File "/private/tmp/test.py", line 14, in <module>
    asyncio.run(main())
    ~~~~~~~~~~~^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.14/3.14.0/Frameworks/Python.framework/Versions/3.14/lib/python3.14/asyncio/runners.py", line 204, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/python@3.14/3.14.0/Frameworks/Python.framework/Versions/3.14/lib/python3.14/asyncio/runners.py", line 127, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/python@3.14/3.14.0/Frameworks/Python.framework/Versions/3.14/lib/python3.14/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/private/tmp/test.py", line 11, in main
    user = await gh.get_self()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/maksym.ivanov/Library/Python/3.14/lib/python/site-packages/github/client.py", line 215, in get_self
    return User(await self.http.get_self(), self.http)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maksym.ivanov/Library/Python/3.14/lib/python/site-packages/github/http.py", line 188, in get_self
    result = await self.session.get(SELF_URL)
                   ^^^^^^^^^^^^
AttributeError: 'http' object has no attribute 'session'

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions