From 5110b03905799d9846d5be22f43782d6ae27a2fa Mon Sep 17 00:00:00 2001 From: likang Date: Thu, 26 Jun 2014 10:41:47 +0800 Subject: [PATCH] Assume all config files are encoded in UTF-8 --- tornado/options.py | 4 ++-- tornado/test/options_test.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tornado/options.py b/tornado/options.py index fd97f31f3..12d2c8017 100644 --- a/tornado/options.py +++ b/tornado/options.py @@ -265,7 +265,7 @@ class OptionParser(object): return remaining - def parse_config_file(self, path, final=True, encoding=None): + def parse_config_file(self, path, final=True): """Parses and loads the Python config file at the given path. If ``final`` is ``False``, parse callbacks will not be run. @@ -275,7 +275,7 @@ class OptionParser(object): config = {} try: # python 3 - with open(path, encoding=encoding) as f: + with open(path, encoding="utf-8") as f: exec_in(f.read(), config, config) except TypeError: # python 2 diff --git a/tornado/test/options_test.py b/tornado/test/options_test.py index 82c4495fd..f90c30d25 100644 --- a/tornado/test/options_test.py +++ b/tornado/test/options_test.py @@ -34,9 +34,8 @@ class OptionsTest(unittest.TestCase): options = OptionParser() options.define("port", default=80) options.define("username", default='foo') - cfg_path = os.path.join(os.path.dirname(__file__), "options_test.cfg") - options.parse_config_file(cfg_path, encoding="utf-8") - + options.parse_config_file(os.path.join(os.path.dirname(__file__), + "options_test.cfg")) self.assertEquals(options.port, 443) self.assertEqual(options.username, "李康") -- 2.47.2