Repository: conan-io/conan

Issue:
tool.vcvars_dict failed if filter_known_paths=True
[Failed this](https://github.com/conan-io/conan/blob/1.9.1/conans/client/tools/win.py#L460)

OS Windows 7, Conan version 1.9.1, Python 2.7.15
(also class 'list' don`t have method 'split' on Python 3)

My code (in conanfile.py):

    def get_build_environment(self):
        env = {}
        if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
            try:
                env = tools.vcvars_dict(self.settings, filter_known_paths=True, force=True)
            except:
                traceback.print_exc()
                raise
            toolset = str(self.settings.compiler.get_safe("toolset"))
            if toolset.endswith("_xp"):
                import find_sdk_winxp
                env = find_sdk_winxp.dict_append(self.settings.arch, env=env)
        return env

Console log:
```
boost/1.68.0@odant/tt: Calling build()
boost/1.68.0@odant/tt: -------------- Bootstrap ------------------------
Traceback (most recent call last):
  File "D:\.conan\data\boost\1.68.0\odant\tt\export\conanfile.py", line 171, in get_build_environment
    env = tools.vcvars_dict(self.settings, filter_known_paths=True, force=True)
  File "D:\Python27\lib\site-packages\conans\client\tools\win.py", line 460, in vcvars_dict
    path = new_env.get("PATH", "").split(";")
AttributeError: 'list' object has no attribute 'split'
boost/1.68.0@odant/tt:
boost/1.68.0@odant/tt: ERROR: Package '74d6e6f7d63123455b1033138a5a462ab0736c21' build failed
boost/1.68.0@odant/tt: WARN: Build folder D:/.conan/s\4w_jf4\1
ERROR: boost/1.68.0@odant/tt: Error in build() method, line 80
        b2 = self.bootstrap(source_folder)
while calling 'bootstrap', line 101
        env = self.get_build_environment()
while calling 'get_build_environment', line 171
        env = tools.vcvars_dict(self.settings, filter_known_paths=True, force=True)
        AttributeError: 'list' object has no attribute 'split'
```


Discussion:
Thanks, I'm on it, we will try to release the `1.9.2` with this bug fixed next week probably.

Resolving patch:
diff --git a/conans/__init__.py b/conans/__init__.py
--- a/conans/__init__.py
+++ b/conans/__init__.py
@@ -18,5 +18,5 @@
 REVISIONS = "revisions"  # Only when enabled in config, not by default look at server_launcher.py
 SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, ]  # Still without v2 because it is changing
 
-__version__ = '1.9.1'
+__version__ = '1.9.2'
 
diff --git a/conans/client/tools/win.py b/conans/client/tools/win.py
--- a/conans/client/tools/win.py
+++ b/conans/client/tools/win.py
@@ -457,9 +457,10 @@ def relevant_path(path):
             keywords = "msbuild", "visual", "microsoft", "/msvc/", "/vc/", "system32", "windows"
             return any(word in path for word in keywords)
 
-        path = new_env.get("PATH", "").split(";")
-        path = [entry for entry in path if relevant_path(entry)]
-        new_env["PATH"] = ";".join(path)
+        path_key = next((name for name in new_env.keys() if "path" == name.lower()), None)
+        if path_key:
+            path = [entry for entry in new_env.get(path_key, "") if relevant_path(entry)]
+            new_env[path_key] = ";".join(path)
 
     return new_env
 


Test patch:
diff --git a/conans/test/util/tools_test.py b/conans/test/util/tools_test.py
--- a/conans/test/util/tools_test.py
+++ b/conans/test/util/tools_test.py
@@ -801,6 +801,24 @@ def vcvars_env_not_duplicated_path_test(self):
                         # If the entry was already repeated before calling "tools.vcvars" we keep it
                         self.fail("The key '%s' has been repeated" % value)
 
+    @unittest.skipUnless(platform.system() == "Windows", "Requires Windows")
+    def vcvars_filter_known_paths_test(self):
+        settings = Settings.loads(default_settings_yml)
+        settings.os = "Windows"
+        settings.compiler = "Visual Studio"
+        settings.compiler.version = "15"
+        settings.arch = "x86"
+        settings.arch_build = "x86_64"
+        with tools.environment_append({"PATH": ["custom_path", "WindowsFake"]}):
+            tmp = tools.vcvars_dict(settings, only_diff=False, filter_known_paths=True)
+            with tools.environment_append(tmp):
+                self.assertNotIn("custom_path", os.environ["PATH"])
+                self.assertIn("WindowsFake",  os.environ["PATH"])
+            tmp = tools.vcvars_dict(settings, only_diff=False, filter_known_paths=False)
+            with tools.environment_append(tmp):
+                self.assertIn("custom_path", os.environ["PATH"])
+                self.assertIn("WindowsFake", os.environ["PATH"])
+
     @unittest.skipUnless(platform.system() == "Windows", "Requires Windows")
     def vcvars_amd64_32_cross_building_support_test(self):
         # amd64_x86 crossbuilder