]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Assume all config files are encoded in UTF-8 1086/head
authorlikang <i@likang.me>
Thu, 26 Jun 2014 02:41:47 +0000 (10:41 +0800)
committerlikang <i@likang.me>
Thu, 26 Jun 2014 02:41:47 +0000 (10:41 +0800)
tornado/options.py
tornado/test/options_test.py

index fd97f31f3ffbb617290e6677daf0cd580d4589d7..12d2c8017dcbcdf817e7e4eda375b90bbf53ab76 100644 (file)
@@ -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
index 82c4495fd4d3ec74b9edcec4fa18d4a620acbbb1..f90c30d251d15ea795947d0701786dcc81d26632 100644 (file)
@@ -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, "李康")