Skip to content

modulemd_defaults.profiles is mutable #88

@rohanpm

Description

@rohanpm

Summary

modulemd_defaults.profiles is declared as a dict, which is a mutable type. This is bad as it makes instances of ModulemdDefaultsUnit dangerous to hash or to use from threads.

It is a goal that the model classes are immutable wherever possible. For list fields, we achieved that by using frozen lists. Similarly, if we have dicts, those should be frozen dicts to keep instances immutable.

Issue Type

  • Bug Report

Steps to reproduce

  • Create a ModulemdDefaultsUnit with profiles={}
  • Change the contents of profiles

Actual results

Changing contents of profiles is possible. If the ModulemdDefaultsUnit was used in a set or as a dict key, bad things happen.

Expected results

Attempting to change contents of profiles causes an exception to be raised.

Additional Information

I think the best solution to this would be for 'profiles' not to be a raw dict at all but some properly modelled type, similarly as done for MaintenanceEntry, but I note this wouldn't be backwards-compatible. Profiles being a raw dict means one can't be confident the dict has the right structure or that it's not being abused.

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