From 342f3ce8248923f41d22faf65926da9a2176439f Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Fri, 31 Mar 2023 13:20:04 -0700 Subject: [PATCH] Fix pretty list printer to handle nulls (flutter/engine#40825) Fix pretty list printer to handle nulls --- engine/src/flutter/impeller/tools/malioc_diff.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/impeller/tools/malioc_diff.py b/engine/src/flutter/impeller/tools/malioc_diff.py index d7fdbbe6c2..2c675656ee 100755 --- a/engine/src/flutter/impeller/tools/malioc_diff.py +++ b/engine/src/flutter/impeller/tools/malioc_diff.py @@ -180,8 +180,12 @@ def read_malioc_tree(malioc_tree): # a space of `width` characters, and separated by `sep`. The separator does not # count against the `width`. If `width` is 0, then the width is unconstrained. def pretty_list(lst, fmt='s', sep='', width=12): - return (sep.join(['{:<{width}{fmt}}'] * len(lst))).format( - width='' if width == 0 else width, fmt=fmt, *lst + formats = [ + '{:<{width}{fmt}}' if ele is not None else '{:<{width}s}' for ele in lst + ] + sanitized_list = [x if x is not None else 'null' for x in lst] + return (sep.join(formats)).format( + width='' if width == 0 else width, fmt=fmt, *sanitized_list )