Skip to content

urllib.request:AttributeError: 'dict' object has no attribute 'get_all' in http_error_auth_reqed function #89735

Closed

Description

@sxt1001
mannequin
BPO 45572
Nosy @Fidget-Spinner, @akulakov
PRs
  • gh-89735: documented *headers* param for urllib.request.http_error_auth_reqed() #30814
  • Files
  • 3.7.4 hang on.png
  • 3.7.4 fix Regex ok.png
  • 3.7.12 fail.png
  • 3.11.0a1 fail.png
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-10-22.13:35:34.228>
    labels = ['type-bug', '3.8', '3.9', '3.10', '3.11', '3.7', 'library']
    title = "urllib.request:AttributeError: 'dict' object has no attribute 'get_all' in http_error_auth_reqed function"
    updated_at = <Date 2022-01-23.00:57:40.389>
    user = 'https://bugs.python.org/sxt1001'

    bugs.python.org fields:

    activity = <Date 2022-01-23.00:57:40.389>
    actor = 'vstinner'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-10-22.13:35:34.228>
    creator = 'sxt1001'
    dependencies = []
    files = ['50386', '50387', '50388', '50389']
    hgrepos = []
    issue_num = 45572
    keywords = ['patch']
    message_count = 3.0
    messages = ['404767', '406813', '411318']
    nosy_count = 3.0
    nosy_names = ['kj', 'andrei.avk', 'sxt1001']
    pr_nums = ['30814']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45572'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

    Linked PRs

    Activity

    1. sxt1001 commented on Oct 22, 2021

      sxt1001mannequin
      MannequinAuthor

      The python version I currently use in my development environment is 3.7.4. Using the following script, the program has never output, and seems to have entered an infinite loop.

      To reproduce the issue we can use the following code:

      from urllib.request import AbstractBasicAuthHandler
      auth_handler = AbstractBasicAuthHandler()
      header = {'www-authenticate': 'Basic ' + ',' * 64 + ' ' + 'foo' + ' ' +'realm'}
      auth_handler.http_error_auth_reqed('www-authenticate','unused','unused',header)

      So I tried to upgrade it to version 3.7.12, and the program will directly report an error. The information is as follows:

      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/usr/local/lib/python3.7/urllib/request.py", line 990, in http_error_auth_reqed
          headers = headers.get_all(authreq)
      AttributeError: 'dict' object has no attribute 'get_all'

      This problem also exists when I upgrade Python 3 to 3.11.0a1. In Python version 3.7.4, the cause of program hang on seems to be a security vulnerability. Refer to https://bugs.python.org/issue39503. The reason for CVE is not the wrong type of headers. However, after repairing CVE, it seems that the type of headers is limited? For the CVE patch, I tried to only fix the part of the regular expression, and the program can run. So, after repairing CVE-2020-8492, what type should the headers parameter be for http_error_auth_reqed function? Based on the current code, how should I adapt and modify it to make it run normally?

    2. added
      3.11only security fixes
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Oct 22, 2021
    3. 9 remaining items

    4. added
      docsDocumentation in the Doc dir
      3.13only security fixes
      3.14bugs and security fixes
      3.15bugs and security fixes
      3.16new features, bugs and security fixes
      and removed on Aug 12, 2026
    5. added a commit that references this issue on Sep 3, 2026
    6. added 2 commits that reference this issue on Sep 3, 2026
    7. added a commit that references this issue on Sep 5, 2026
    8. added a commit that references this issue on Sep 12, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.13only security fixes3.14bugs and security fixes3.15bugs and security fixes3.16new features, bugs and security fixesdocsDocumentation in the Doc dirstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions