Skip to content

Commit a592001

Browse files
authored
Merge pull request SCons#4507 from mwichmann/maint/pickling
Remove redundant node-info code
2 parents 55b386b + bc08be0 commit a592001

File tree

5 files changed

+6
-94
lines changed

5 files changed

+6
-94
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
2727
json output is also sorted, to match the default display.
2828
- Python 3.13 (alpha) changes the behavior of isabs() on Windows. Adjust
2929
SCons usage of in NodeInfo classes to match. Fixes #4502, #4504.
30+
- Drop duplicated __getstate__ and __setstate__ methods in AliasNodeInfo,
31+
FileNodeInfo and ValueNodeInfo classes, as they are identical to the
32+
ones in parent NodeInfoBase and can just be inherited.
3033

3134

3235
RELEASE 4.7.0 - Sun, 17 Mar 2024 17:22:20 -0700

RELEASE.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY
3131
json output is also sorted, to match the default display.
3232
- Python 3.13 changes the behavior of isabs() on Windows. Adjust SCons
3333
usage of this in NodeInfo classes to avoid test problems.
34+
- Drop duplicated __getstate__ and __setstate__ methods in AliasNodeInfo,
35+
FileNodeInfo and ValueNodeInfo classes, as they are identical to the
36+
ones in parent NodeInfoBase and can just be inherited.
3437
- All exceptions during the execution of an Action are now returned by value
3538
rather than by raising an exception, for more consistent behavior.
3639
NOTE: With this change, user created Actions should now catch and handle

SCons/Node/Alias.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,38 +57,6 @@ class AliasNodeInfo(SCons.Node.NodeInfoBase):
5757
def str_to_node(self, s):
5858
return default_ans.Alias(s)
5959

60-
def __getstate__(self):
61-
"""
62-
Return all fields that shall be pickled. Walk the slots in the class
63-
hierarchy and add those to the state dictionary. If a '__dict__' slot is
64-
available, copy all entries to the dictionary. Also include the version
65-
id, which is fixed for all instances of a class.
66-
"""
67-
state = getattr(self, '__dict__', {}).copy()
68-
for obj in type(self).mro():
69-
for name in getattr(obj,'__slots__',()):
70-
if hasattr(self, name):
71-
state[name] = getattr(self, name)
72-
73-
state['_version_id'] = self.current_version_id
74-
try:
75-
del state['__weakref__']
76-
except KeyError:
77-
pass
78-
79-
return state
80-
81-
def __setstate__(self, state) -> None:
82-
"""
83-
Restore the attributes from a pickled state.
84-
"""
85-
# TODO check or discard version
86-
del state['_version_id']
87-
for key, value in state.items():
88-
if key not in ('__weakref__',):
89-
setattr(self, key, value)
90-
91-
9260
class AliasBuildInfo(SCons.Node.BuildInfoBase):
9361
__slots__ = ()
9462
current_version_id = 2

SCons/Node/FS.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,37 +2532,6 @@ def str_to_node(self, s):
25322532
s = top.get_labspath() + '/' + s
25332533
return root._lookup_abs(s, Entry)
25342534

2535-
def __getstate__(self):
2536-
"""
2537-
Return all fields that shall be pickled. Walk the slots in the class
2538-
hierarchy and add those to the state dictionary. If a '__dict__' slot is
2539-
available, copy all entries to the dictionary. Also include the version
2540-
id, which is fixed for all instances of a class.
2541-
"""
2542-
state = getattr(self, '__dict__', {}).copy()
2543-
for obj in type(self).mro():
2544-
for name in getattr(obj, '__slots__', ()):
2545-
if hasattr(self, name):
2546-
state[name] = getattr(self, name)
2547-
2548-
state['_version_id'] = self.current_version_id
2549-
try:
2550-
del state['__weakref__']
2551-
except KeyError:
2552-
pass
2553-
2554-
return state
2555-
2556-
def __setstate__(self, state) -> None:
2557-
"""
2558-
Restore the attributes from a pickled state.
2559-
"""
2560-
# TODO check or discard version
2561-
del state['_version_id']
2562-
for key, value in state.items():
2563-
if key not in ('__weakref__',):
2564-
setattr(self, key, value)
2565-
25662535
def __eq__(self, other):
25672536
return self.csig == other.csig and self.timestamp == other.timestamp and self.size == other.size
25682537

SCons/Node/Python.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,6 @@ class ValueNodeInfo(SCons.Node.NodeInfoBase):
3737
def str_to_node(self, s):
3838
return ValueWithMemo(s)
3939

40-
def __getstate__(self):
41-
"""
42-
Return all fields that shall be pickled. Walk the slots in the class
43-
hierarchy and add those to the state dictionary. If a '__dict__' slot
44-
is available, copy all entries to the dictionary. Also include the
45-
version id, which is fixed for all instances of a class.
46-
"""
47-
state = getattr(self, '__dict__', {}).copy()
48-
for obj in type(self).mro():
49-
for name in getattr(obj, '__slots__', ()):
50-
if hasattr(self, name):
51-
state[name] = getattr(self, name)
52-
53-
state['_version_id'] = self.current_version_id
54-
try:
55-
del state['__weakref__']
56-
except KeyError:
57-
pass
58-
59-
return state
60-
61-
def __setstate__(self, state) -> None:
62-
"""
63-
Restore the attributes from a pickled state.
64-
"""
65-
# TODO check or discard version
66-
del state['_version_id']
67-
for key, value in state.items():
68-
if key not in ('__weakref__',):
69-
setattr(self, key, value)
70-
7140

7241
class ValueBuildInfo(SCons.Node.BuildInfoBase):
7342
__slots__ = ()

0 commit comments

Comments
 (0)