Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Python 3.10+ compatibility broken: collections.Mapping import error #1352

@avinxshKD

Description

@avinxshKD

Running OWTF on Python 3.10 or later crashes immediately due to a deprecated import in owtf/utils/http.py. The code uses collections.Mapping, which was moved to collections.abc in Python 3.3 and completely removed from the top-level collections namespace in Python 3.10.

Error:
AttributeError: module 'collections' has no attribute 'Mapping'

Affected file: owtf/utils/http.py (line 44)

The deep_update() function imports collections and uses isinstance(value, collections.Mapping) which breaks on Python 3.10+.

This is a critical issue since Python 3.9 is EOL and most modern systems (Ubuntu 22.04+, Fedora 36+) ship with Python 3.10 or 3.11.

Fix is straightforward - replace:
import collections
isinstance(value, collections.Mapping)

with:
from collections.abc import Mapping
isinstance(value, Mapping)

This maintains backward compatibility with Python 3.3+ while fixing the crash on newer versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions