Skip to content

auto_exc's hashing behavior and its documentation do not match #543

@gabbard

Description

@gabbard

The documentation for auto_exc says:

  - the values for *cmp* and *hash* are ignored and the instances compare
          and hash by the instance's ids (N.B. ``attrs`` will *not* remove
          existing implementations of ``__hash__`` or the equality methods. It
          just won't add own ones.),

However, the test for auto_exc says:

    Classes with auto_exc=True have a Exception-style __str__, are neither
        comparable nor hashable, and store the fields additionally in
        self.args.

and tests:

            with pytest.raises(TypeError):
                hash(e)

The documentation and the code should be made consistent. I noticed this because unittest complained that the exception type was unhashable when thrown from a test and I see some references to logging expecting hashable exceptions, so the documented behavior is probably better than the implemented behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions