Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] AttributePropery with mutable, non-auto-create default loses its value on restart #3524

Open
chiizujin opened this issue Apr 29, 2024 · 0 comments
Labels
bug An actual error or unwanted behavior. needs-triage Yet to be looked at and verified as an a real issue/feature that could be worked on

Comments

@chiizujin
Copy link
Contributor

This seems to be a recurrence of #3488 (resolved by b8e37f9)

I can't recall how much I tested this after the above fix but I am still seeing this happening. Here is a more basic example:

Using this object:

class TestObject(Object):
    test_list = AttributeProperty(list, autocreate=False)
    test_dict = AttributeProperty(dict, autocreate=False)
>py self.search("test").test_list
[]

>py self.search("test").test_list.append(1)

>py self.search("test").test_list
[1]

>restart
(...)

>py self.search("test").test_list
[]

If an empty list is assigned to the proprty first, it works as expected:

>py self.search("test").test_list = []
>py self.search("test").test_list.append(1)
>py self.search("test").test_list
[1]

>restart
(...)

>py self.search("test").test_list
[1]

Similarly for a dictionary:

>self.search("test").test_dict
{}

>py self.search("test").test_dict[1] = 1

>py self.search("test").test_dict
{1: 1}

>restart
(...)

>py self.search("test").test_dict
{}

Again, it works as expected if assigning first:

>py self.search("test").test_dict = {}
>py self.search("test").test_dict[1] = 1
>py self.search("test").test_dict
{1: 1}

>restart
(...)

>py self.search("test").test_dict
{1: 1}

I have not tested sets but I suspect they may have the same issue.

This does not occur with autocreate=True.

@chiizujin chiizujin added bug An actual error or unwanted behavior. needs-triage Yet to be looked at and verified as an a real issue/feature that could be worked on labels Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An actual error or unwanted behavior. needs-triage Yet to be looked at and verified as an a real issue/feature that could be worked on
Projects
None yet
Development

No branches or pull requests

1 participant