Commit 02eb41d9 authored by Jason Madden's avatar Jason Madden

Do not print locals that have no values. Fixes #1275.

parent 1afdb093
......@@ -7,7 +7,8 @@
1.3.7 (unreleased)
==================
- Nothing changed yet.
- Formatting run info no longer includes ``gevent.local.local``
objects that have no value in the greenlet. See :issue:`1275`.
1.3.6 (2018-08-17)
......
......@@ -371,6 +371,8 @@ class GreenletTree(object):
if gr_locals:
tree.child_data("Greenlet Locals:")
for (kind, idl), vals in gr_locals:
if not vals:
continue # not set in this greenlet; ignore it.
tree.child_data(" Local %s at %s" % (kind, hex(idl)))
tree.child_multidata(" " + pprint.pformat(vals))
......
......@@ -43,6 +43,9 @@ class TestFormat(greentest.TestCase):
def root():
l = MyLocal(42)
assert l
# And an empty local.
l2 = local.local()
assert l2
gevent.getcurrent().spawn_tree_locals['a value'] = 42
io = NativeStrIO()
g = gevent.spawn(util.print_run_info, file=io)
......@@ -54,12 +57,15 @@ class TestFormat(greentest.TestCase):
g.join()
value = g.value
self.assertIn("Spawned at", value)
self.assertIn("Parent:", value)
self.assertIn("Spawn Tree Locals", value)
self.assertIn("Greenlet Locals:", value)
self.assertIn('MyLocal', value)
self.assertIn("Printer", value) # The name is printed
# Empty locals should not be printed
self.assertNotIn('{}', value)
@greentest.skipOnPyPy("See TestFormat")
class TestTree(greentest.TestCase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment