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