From 85d9ab4d5c2d2afd3c36229a771f77e4536853cf Mon Sep 17 00:00:00 2001 From: Peter Eckersley Date: Thu, 21 Jul 2016 13:39:13 -0700 Subject: [PATCH] UnspacedList._spaced_position: support the slice at the end fo the list - Which is needed for .insert()ing at the end, for instance. --- certbot-nginx/certbot_nginx/nginxparser.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/certbot-nginx/certbot_nginx/nginxparser.py b/certbot-nginx/certbot_nginx/nginxparser.py index 1859777d8..a4d4a452f 100644 --- a/certbot-nginx/certbot_nginx/nginxparser.py +++ b/certbot-nginx/certbot_nginx/nginxparser.py @@ -279,6 +279,9 @@ class UnspacedList(list): # Normalize indexes like list[-1] etc, and save the result if idx < 0: idx = len(self) + idx + if idx == len(self): + # not an index, but the slice at the end of the list + return len(self.spaced) if not 0 <= idx < len(self): raise IndexError("list index out of range") idx0 = idx