Bug 1559975 - enable py2 and py3 linting in memory r=ahal
authorNick Thomas <nthomas@mozilla.com>
Fri, 28 Jun 2019 18:53:28 +0000
changeset 543415 9806cabfaa7514c420d1ece4d4256f75e525a625
parent 543414 4c7e3b86897452bd41104b676a16d97a77296eb9
child 543416 4c6399a9e8aeeecfe2f66f7353946b3ed4aae999
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1559975
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1559975 - enable py2 and py3 linting in memory r=ahal Differential Revision: https://phabricator.services.mozilla.com/D35251
memory/replace/dmd/block_analyzer.py
memory/replace/dmd/dmd.py
memory/replace/dmd/test/scan-test.py
memory/replace/logalloc/replay/logalloc_munge.py
tools/lint/py2.yml
tools/lint/py3.yml
--- a/memory/replace/dmd/block_analyzer.py
+++ b/memory/replace/dmd/block_analyzer.py
@@ -4,16 +4,18 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # From a scan mode DMD log, extract some information about a
 # particular block, such as its allocation stack or which other blocks
 # contain pointers to it. This can be useful when investigating leaks
 # caused by unknown references to refcounted objects.
 
+from __future__ import absolute_import, print_function
+
 import json
 import gzip
 import sys
 import argparse
 import re
 
 
 # The DMD output version this script handles.
--- a/memory/replace/dmd/dmd.py
+++ b/memory/replace/dmd/dmd.py
@@ -1,17 +1,17 @@
 #! /usr/bin/env python
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 '''This script analyzes a JSON file emitted by DMD.'''
 
-from __future__ import print_function, division
+from __future__ import absolute_import, print_function, division
 
 import argparse
 import collections
 import gzip
 import json
 import os
 import platform
 import re
@@ -587,21 +587,18 @@ def printDigest(args, digest):
             out('  {:} block{:} in heap block record {:,d} of {:,d}'.
                 format(number(record.numBlocks),
                        plural(record.numBlocks), i, numRecords))
             out('  {:} bytes ({:} requested / {:} slop)'.
                 format(number(record.usableSize),
                        number(record.reqSize),
                        number(record.slopSize)))
 
-            def abscmp((usableSize1, _1), (usableSize2, _2)): return \
-                cmp(abs(usableSize1), abs(usableSize2))
-            usableSizes = sorted(record.usableSizes.items(), cmp=abscmp,
-                                 reverse=True)
-
+            usableSizes = sorted(record.usableSizes.items(),
+                                 key=lambda x: abs(x[0]), reverse=True)
             hasSingleBlock = len(usableSizes) == 1 and usableSizes[0][1] == 1
 
             if not hasSingleBlock:
                 out('  Individual block sizes: ', end='')
                 if len(usableSizes) == 0:
                     out('(no change)', end='')
                 else:
                     isFirst = True
--- a/memory/replace/dmd/test/scan-test.py
+++ b/memory/replace/dmd/test/scan-test.py
@@ -1,17 +1,17 @@
 #! /usr/bin/env python
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 '''Testing for the JSON file emitted by DMD heap scan mode when running SmokeDMD.'''
 
-from __future__ import print_function, division
+from __future__ import absolute_import, print_function, division
 
 import argparse
 import gzip
 import json
 import sys
 
 # The DMD output version this script handles.
 outputVersion = 5
--- a/memory/replace/logalloc/replay/logalloc_munge.py
+++ b/memory/replace/logalloc/replay/logalloc_munge.py
@@ -13,17 +13,17 @@ Given the following output:
 The resulting output is:
   1 malloc(42)=#1
   1 malloc(24)=#2
   1 free(#1)
 
 See README for more details.
 """
 
-from __future__ import print_function
+from __future__ import absolute_import, print_function
 import sys
 from collections import (
     defaultdict,
     deque,
 )
 
 
 class IdMapping(object):
--- a/tools/lint/py2.yml
+++ b/tools/lint/py2.yml
@@ -14,17 +14,16 @@ py2:
         - editor
         - gfx
         - intl
         - ipc
         - js/src
         - js/xpconnect
         - layout
         - media
-        - memory
         - mobile
         - modules
         - mozglue
         - netwerk
         - nsprpub
         - other-licenses
         - python/devtools
         - python/mach
--- a/tools/lint/py3.yml
+++ b/tools/lint/py3.yml
@@ -14,17 +14,16 @@ py3:
         - dom/media/test
         - gfx
         - ipc/ipdl
         - js/src
         - layout/reftests
         - layout/style
         - layout/tools/reftest
         - media
-        - memory/replace
         - modules/freetype2
         - python/safety
         - security/manager/ssl
         - servo
         - testing/awsy
         - testing/mochitest
         - testing/mozharness
         - testing/raptor