From 98c1553af9b8e4122d1d7cad1f28d7ea0e932326 Mon Sep 17 00:00:00 2001 From: Hong Hui Xiao Date: Tue, 11 Sep 2018 09:05:33 +0000 Subject: [PATCH] Python3 complains when iterate bytes string Using Python3 to iterate a bytes string, int will be presented. However, in Python2, str will be presented. Closes-Bug: #1792120 Change-Id: Id30f5f1da989fdb71e0f9b627e875e0c41f89b30 --- dragonflow/controller/apps/dhcp.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dragonflow/controller/apps/dhcp.py b/dragonflow/controller/apps/dhcp.py index a08ebe3f7..da4817649 100644 --- a/dragonflow/controller/apps/dhcp.py +++ b/dragonflow/controller/apps/dhcp.py @@ -280,7 +280,12 @@ class DHCPApp(df_base_app.DFlowApp): return {} for opt in requested_opts: - opt_int = ord(opt) + # For python3 opt is already int. + if isinstance(opt, str): + opt_int = ord(opt) + else: + opt_int = opt + if opt_int in default_opts: # already answered by the default options continue