Isort: [Windows] WinError 123 raised for isort >= 4.3.5

Created on 25 Feb 2019  路  10Comments  路  Source: PyCQA/isort

After upgrading from v4.3.4, I'm getting these errors under Python 3.7.1 on Windows 10. Let me know if you need any other detail.

(env) X:\umami>isort -rc guildmaster
WARNING: Unable to parse file guildmaster\admin.py due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/X:\\umami\\guildmaster\\admin.py'
WARNING: Unable to parse file guildmaster\apps.py due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/X:\\umami\\guildmaster\\apps.py'
WARNING: Unable to parse file guildmaster\conf.py due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/X:\\umami\\guildmaster\\conf.py'
WARNING: Unable to parse file guildmaster\forms.py due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/X:\\umami\\guildmaster\\forms.py'
WARNING: Unable to parse file guildmaster\models.py due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/X:\\umami\\guildmaster\\models.py'
WARNING: Unable to parse file guildmaster\tests.py due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/X:\\umami\\guildmaster\\tests.py'
WARNING: Unable to parse file guildmaster\urls.py due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/X:\\umami\\guildmaster\\urls.py'
WARNING: Unable to parse file guildmaster\views.py due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/X:\\umami\\guildmaster\\views.py'
WARNING: Unable to parse file guildmaster\__init__.py due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/X:\\umami\\guildmaster\\__init__.py'
WARNING: Unable to parse file guildmaster\migrations\0001_initial.py due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/X:\\umami\\guildmaster\\migrations\\0001_initial.py'
WARNING: Unable to parse file guildmaster\migrations\__init__.py due to [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/X:\\umami\\guildmaster\\migrations\\__init__.py'
bug

Most helpful comment

This should be fixed in the 4.3.10 release of isort: https://github.com/timothycrosley/isort/releases/tag/4.3.10

I am very sorry that Windows compatibility slipped in the last set of releases! It has always been my intention to have full compatibility across Operating Systems and that is why AppVeyor integration was in place. At some point that integration stopped working, I'm not sure yet what caused that. However, I have ensured it is operational again, and I've even spent the money to make sure I have a Windows test VM of my own to ensure compatibility in the future.

Thank you everyone!

~Timothy

All 10 comments

I'm getting a lot of this also.

I get the same error running isort both directly and through flake8-isort, though the flake8-isort traceback looks like it could be more useful.

Traceback (most recent call last):
  File "C:\Program Files\Python37\Lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files\Python37\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\james\Projects\phial\venv\Scripts\flake8.exe\__main__.py", line 9, in <module>
  File "c:\users\james\projects\phial\venv\lib\site-packages\flake8\main\cli.py", line 18, in main
    app.run(argv)
  File "c:\users\james\projects\phial\venv\lib\site-packages\flake8\main\application.py", line 394, in run
    self._run(argv)
  File "c:\users\james\projects\phial\venv\lib\site-packages\flake8\main\application.py", line 382, in _run
    self.run_checks()
  File "c:\users\james\projects\phial\venv\lib\site-packages\flake8\main\application.py", line 301, in run_checks
    self.file_checker_manager.run()
  File "c:\users\james\projects\phial\venv\lib\site-packages\flake8\checker.py", line 330, in run
    self.run_serial()
  File "c:\users\james\projects\phial\venv\lib\site-packages\flake8\checker.py", line 314, in run_serial
    checker.run_checks()
  File "c:\users\james\projects\phial\venv\lib\site-packages\flake8\checker.py", line 608, in run_checks
    self.run_ast_checks()
  File "c:\users\james\projects\phial\venv\lib\site-packages\flake8\checker.py", line 504, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "c:\users\james\projects\phial\venv\lib\site-packages\flake8_isort.py", line 79, in run
    show_diff=True,
  File "c:\users\james\projects\phial\venv\lib\site-packages\isort\isort.py", line 96, in __init__
    if settings.should_skip(file_path, self.config):
  File "c:\users\james\projects\phial\venv\lib\site-packages\isort\settings.py", line 340, in should_skip
    if stat.S_ISFIFO(os.stat(normalized_path).st_mode):
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '/C:\\Users\\james\\Projects\\phial\\phial\\bot.py'

The last line seems to indicate the error is on this line of code which looks like it was updated just before the release of 4.3.5.

Unfortunately I don't understand what this line is doing and don't have time to try and figure it out right now, but if I can figure it out later or someone can give me a pointer then I'm happy to open a PR if I can find a fix.

It looks like PR #810 may have introduced the issue. This line prepends a '/', which causes os.stat to fail.

I'll take a stab at this tonight.

I see in this commit two years ago that the code was changed from using os.path to posixpath, but I'm curious if that decision should be reevaluated. From posixpath's docstring:

Instead of importing this module directly, import os and refer to
this module as os.path. The "os.path" name is an alias for this
module on Posix systems; on other systems (e.g. Windows),
os.path provides the same operations in a manner specific to that
platform, and is an alias to another module (e.g. ntpath).

It looks like the specific break may be from https://github.com/timothycrosley/isort/issues/792, since it results in stating the file path, which breaks on windows. Perhaps this can be cleaned up and improved by using os.path.isfile (and maybe related isdir/islink) instead of stat.S_ISFIFO. For checking the skip path, maybe os.path.samefile is a better choice.

I see an appveyor.yml config in the repo, but the pull requests don't seem to be triggering appveyor jobs. Would be nice if that integration was (re)enabled so there would be some early indication about breaking changes on Windows.

Also affected 馃憤

This should be fixed in the 4.3.10 release of isort: https://github.com/timothycrosley/isort/releases/tag/4.3.10

I am very sorry that Windows compatibility slipped in the last set of releases! It has always been my intention to have full compatibility across Operating Systems and that is why AppVeyor integration was in place. At some point that integration stopped working, I'm not sure yet what caused that. However, I have ensured it is operational again, and I've even spent the money to make sure I have a Windows test VM of my own to ensure compatibility in the future.

Thank you everyone!

~Timothy

4.3.10 works for me on Windows, thanks!

Confirmed, working for me as well. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

donjar picture donjar  路  3Comments

whg517 picture whg517  路  3Comments

ionelmc picture ionelmc  路  3Comments

lee-kagiso picture lee-kagiso  路  4Comments

darkclouder picture darkclouder  路  3Comments