[tor-commits] [stem/master] Don't load vim swap files as configurations

atagar at torproject.org atagar at torproject.org
Sun Aug 13 21:15:15 UTC 2017


commit a55d9ba5a5410d67db10796868cae997ff07ac36
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Aug 10 10:39:50 2017 -0700

    Don't load vim swap files as configurations
    
    When loading a directory of config files we blindly read everything as configs.
    We should probably skip quite a few things but starting with vim swap files
    since this is just bit me.
---
 docs/change_log.rst | 1 +
 stem/util/conf.py   | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/docs/change_log.rst b/docs/change_log.rst
index 7159288d..ea353a23 100644
--- a/docs/change_log.rst
+++ b/docs/change_log.rst
@@ -77,6 +77,7 @@ The following are only available within Stem's `git repository
   * Added :class:`~stem.util.test_tools.TimedTestRunner` and :func:`~stem.util.test_tools.test_runtimes`
   * Supporing pid arguments in :func:`~stem.util.system.is_running`
   * Normalized :func:`~stem.util.term.format` to return unicode
+  * Don't load vim swap files as configurations
 
  * **Interpreter**
 
diff --git a/stem/util/conf.py b/stem/util/conf.py
index 5691b2a4..d4af467d 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -475,6 +475,9 @@ class Config(object):
     .. versionchanged:: 1.3.0
        Added the **commenting** argument.
 
+    .. versionchanged:: 1.6.0
+       Avoid loading vim swap files.
+
     :param str path: file or directory path to be loaded, this uses the last
       loaded path if not provided
     :param bool commenting: ignore line content after a '#' if **True**, read
@@ -494,6 +497,9 @@ class Config(object):
     if os.path.isdir(self._path):
       for root, dirnames, filenames in os.walk(self._path):
         for filename in filenames:
+          if filename.endswith('.swp'):
+            continue  # vim swap file
+
           self.load(os.path.join(root, filename))
 
       return



More information about the tor-commits mailing list