This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jeffersonqin
Recipients jeffersonqin
Date 2022-03-16.14:24:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1647440675.94.0.131191569547.issue47034@roundup.psfhosted.org>
In-reply-to
Content
For the following code piece:

```
import pickle

class Child:
	def __init__(self, field):
		self.field = field

class Parent:
	child = Child(0.5)

if __name__ == '__main__':
	i = input()
	if i == 'd':
		parent = Parent()
		parent.child.field = 0.6
		pickle.dump(parent, open('test.pkl', 'wb+'))
	else:
		parent = pickle.load(open('test.pkl', 'rb'))
		print(parent.child.field)
```

After dumping, when we load the file throught `pickles.load`, `parent.child.field` is 0.5, and is not 0.6, which we intend it to be.

However, after removing the line `child = Child(0.5)` and moving it to `__init__(self)` of `Parent`, everything works fine.

I'm not sure whether this is indeed an issue. If not, sorry for take your time.
History
Date User Action Args
2022-03-16 14:24:35jeffersonqinsetrecipients: + jeffersonqin
2022-03-16 14:24:35jeffersonqinsetmessageid: <1647440675.94.0.131191569547.issue47034@roundup.psfhosted.org>
2022-03-16 14:24:35jeffersonqinlinkissue47034 messages
2022-03-16 14:24:35jeffersonqincreate