Commit 74ef54b9 authored by Jason Madden's avatar Jason Madden Committed by GitHub

Merge pull request #1276 from gevent/issue1275

Do not print locals that have no values. Fixes #1275.
parents 1afdb093 02eb41d9
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
1.3.7 (unreleased) 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) 1.3.6 (2018-08-17)
......
...@@ -371,6 +371,8 @@ class GreenletTree(object): ...@@ -371,6 +371,8 @@ class GreenletTree(object):
if gr_locals: if gr_locals:
tree.child_data("Greenlet Locals:") tree.child_data("Greenlet Locals:")
for (kind, idl), vals in gr_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_data(" Local %s at %s" % (kind, hex(idl)))
tree.child_multidata(" " + pprint.pformat(vals)) tree.child_multidata(" " + pprint.pformat(vals))
......
...@@ -43,6 +43,9 @@ class TestFormat(greentest.TestCase): ...@@ -43,6 +43,9 @@ class TestFormat(greentest.TestCase):
def root(): def root():
l = MyLocal(42) l = MyLocal(42)
assert l assert l
# And an empty local.
l2 = local.local()
assert l2
gevent.getcurrent().spawn_tree_locals['a value'] = 42 gevent.getcurrent().spawn_tree_locals['a value'] = 42
io = NativeStrIO() io = NativeStrIO()
g = gevent.spawn(util.print_run_info, file=io) g = gevent.spawn(util.print_run_info, file=io)
...@@ -54,12 +57,15 @@ class TestFormat(greentest.TestCase): ...@@ -54,12 +57,15 @@ class TestFormat(greentest.TestCase):
g.join() g.join()
value = g.value value = g.value
self.assertIn("Spawned at", value) self.assertIn("Spawned at", value)
self.assertIn("Parent:", value) self.assertIn("Parent:", value)
self.assertIn("Spawn Tree Locals", value) self.assertIn("Spawn Tree Locals", value)
self.assertIn("Greenlet Locals:", value) self.assertIn("Greenlet Locals:", value)
self.assertIn('MyLocal', value) self.assertIn('MyLocal', value)
self.assertIn("Printer", value) # The name is printed self.assertIn("Printer", value) # The name is printed
# Empty locals should not be printed
self.assertNotIn('{}', value)
@greentest.skipOnPyPy("See TestFormat") @greentest.skipOnPyPy("See TestFormat")
class TestTree(greentest.TestCase): 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