From 3d4f822be0e3f6ff0522a48bda8e0b673bbfb26e Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Tue, 16 Aug 2016 16:41:23 -0700 Subject: [PATCH] Handle case where block is empty -- not sure if it ever happens, but let's not error out unnecessarily --- certbot-nginx/certbot_nginx/parser.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/certbot-nginx/certbot_nginx/parser.py b/certbot-nginx/certbot_nginx/parser.py index 703a33cf1..afea71c26 100644 --- a/certbot-nginx/certbot_nginx/parser.py +++ b/certbot-nginx/certbot_nginx/parser.py @@ -520,8 +520,7 @@ def _add_directives(block, directives, replace): """ for directive in directives: _add_directive(block, directive, replace) - last = block[-1] - if not '\n' in last: # could be " \n " or ["\n"] ! + if block and '\n' not in block[-1]: # could be " \n " or ["\n"] ! block.append(nginxparser.UnspacedList('\n'))