Merge lp:~jelmer/meliae/itervalues into lp:meliae

Proposed by Jelmer Vernooij
Status: Needs review
Proposed branch: lp:~jelmer/meliae/itervalues
Merge into: lp:meliae
Diff against target: 29 lines (+3/-4)
1 file modified
meliae/scanner.py (+3/-4)
To merge this branch: bzr merge lp:~jelmer/meliae/itervalues
Reviewer Review Type Date Requested Status
Meliae Development Team Pending
Review via email: mp+385313@code.launchpad.net

Commit message

Use dict.values rather than dict.itervalues, which is not available on Python 3.

Description of the change

Use dict.values rather than dict.itervalues, which is not available on Python 3.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

Are we missing a test case? The test suite was passing on Python3 but didn't seem to encounter this.

Revision history for this message
John A Meinel (jameinel) wrote :

It seems our Python 3 support isn't quite as complete as we thought:
https://bugs.launchpad.net/meliae/+bug/1883514

The test isn't very robust but just calling dump_gc_objects triggers fatal errors:
+ def test_smoke_dump_gc_objects(self):
+ a_dict = {'some_specialty_content': 'more_content'}
+ t = tempfile.TemporaryFile(prefix='meliae-')
+ t_file = getattr(t, 'file', t)
+ scanner.dump_gc_objects(t_file)
+ t.flush()
+ t.seek(0)
+ content = t_file.read()
+ self.assertIn('some_specialty_content', content)
+

Unmerged revisions

230. By Jelmer Vernooij

Use dict.values rather than dict.itervalues, which is not available on Python3.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'meliae/scanner.py'
2--- meliae/scanner.py 2020-02-03 22:08:03 +0000
3+++ meliae/scanner.py 2020-06-09 13:08:53 +0000
4@@ -93,15 +93,15 @@
5 # In current versions of python, these are all pre-cached
6 nodump.extend(range(-5, 256))
7 nodump.extend([chr(c) for c in range(256)])
8- nodump.extend([t for t in types.__dict__.itervalues()
9- if type(t) is types.TypeType])
10+ nodump.extend([t for t in types.__dict__.values()
11+ if isinstance(t, type)])
12 nodump.extend([set, dict])
13 # Some very common interned strings
14 nodump.extend(('__doc__', 'self', 'operator', '__init__', 'codecs',
15 '__new__', '__builtin__', '__builtins__', 'error', 'len',
16 'errors', 'keys', 'None', '__module__', 'file', 'name', '',
17 'sys', 'True', 'False'))
18- nodump.extend((BaseException, Exception, StandardError, ValueError))
19+ nodump.extend((BaseException, Exception, Exception, ValueError))
20 for obj in nodump:
21 _scanner.dump_object_info(outf, obj, nodump=None, recurse_depth=0)
22 # Avoid dumping the all_objs list and this function as well. This helps
23@@ -146,7 +146,6 @@
24 outf.flush()
25
26
27-
28 def get_recursive_size(obj):
29 """Get the memory referenced from this object.
30

Subscribers

People subscribed via source and target branches

to all changes: