From af8a1de720d5f758a937e5362bebfb15edc21009 2013-09-30 18:14:34 From: MinRK Date: 2013-09-30 18:14:34 Subject: [PATCH] limit random ports to positive values --- diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py index e5d2298..7f8f390 100644 --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -112,7 +112,7 @@ def random_ports(port, n): for i in range(min(5, n)): yield port + i for i in range(n-5): - yield port + random.randint(-2*n, 2*n) + yield max(1, port + random.randint(-2*n, 2*n)) def load_handlers(name): """Load the (URL pattern, handler) tuples for each component."""