Skip to content

AttributeError: 'NoneType' object has no attribute 'errno' #2231

Closed
@steven2308

Description

Long story short

Trying to resolve a domain which is an alias for another one, which does not have an A or CNAME record, raises AttributeError: 'NoneType' object has no attribute 'errno'

Expected behaviour

Raise an error correctly, socket.gaierror probably.

Actual behaviour

  File "xtest.py", line 16, in <module>
    process()
  File "/usr/lib/python3.6/asyncio/base_events.py", line 449, in run_until_complete
    return future.result()
  File "/usr/lib/python3.6/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/myenv/lib/python3.6/site-packages/aiohttp/helpers.py", line 72, in send
    return self._coro.send(arg)
  File "/myenv/lib/python3.6/site-packages/aiohttp/client.py", line 233, in _request
    conn = yield from self._connector.connect(req)
  File "/myenv/lib/python3.6/site-packages/aiohttp/connector.py", line 378, in connect
    proto = yield from self._create_connection(req)
  File "/myenv/lib/python3.6/site-packages/aiohttp/connector.py", line 687, in _create_connection
    _, proto = yield from self._create_direct_connection(req)
  File "/myenv/lib/python3.6/site-packages/aiohttp/connector.py", line 735, in _create_direct_connection
    exc.errno,
AttributeError: 'NoneType' object has no attribute 'errno'

Steps to reproduce

This script will reproduce the error.

import asyncio
import aiohttp
from aiohttp.resolver import AsyncResolver

def process():
    url = 'http://esly.win/'
    resolver = AsyncResolver()
    conn = aiohttp.TCPConnector(resolver=resolver, verify_ssl=False)
    session = aiohttp.ClientSession(connector=conn)
    return session.get(url)

loop = asyncio.get_event_loop()
loop.run_until_complete(
    process()
)

If I use the session without setting the connector it first raises a socket.gaierror but then

During handling of the above exception, another exception occurred...

And the same traceback appears.

Your environment

Python 3.6.0b2
Ubuntu 10.10
aiohttp==2.2,5
Also happens with aiohttp==2.3.0a0 (installed from git on 29/Aug/2017)

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions