Skip to content

Pipe redirection broken on Python2.7 since 4.3.13 #948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ionelmc opened this issue May 14, 2019 · 2 comments
Closed

Pipe redirection broken on Python2.7 since 4.3.13 #948

ionelmc opened this issue May 14, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@ionelmc
Copy link
Contributor

ionelmc commented May 14, 2019

All versions since 4.3.13 (including) produce this problem:

$ echo "import stuff" | isort -
Traceback (most recent call last):
  File "/usr/local/bin/isort", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/isort/main.py", line 339, in main
    SortImports(file_=file_, write_to_stdout=True, **arguments)
  File "/usr/local/lib/python2.7/dist-packages/isort/isort.py", line 140, in __init__
    file_.seek(0)
IOError: [Errno 29] Illegal seek

It would look like #895 is the same bug but then 3.3.15 still produces this problem.

I'll be using 4.3.12 meanwhile ...

@timothycrosley
Copy link
Member

Hi @ionelmc,

Thanks for reporting this issue:

After some investigation, I've confirmed it was fixed for Python3+, but remains broken on Python2:

Python3:

timothy@timothy-Desktop:~$ sudo pip3 install -U isort
Requirement already up-to-date: isort in /usr/local/lib/python3.7/dist-packages (4.3.19)
timothy@timothy-Desktop:~$ echo "import stuff" | isort -
import stuff

Python2.7:

(test_isort_python2) timothy@timothy-Desktop:~$ pip install isort -U
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting isort
  Downloading https://files.pythonhosted.org/packages/ae/ae/5ef4b57e15489754b73dc908b656b02ab0e6d37b190ac78dd498be8b577d/isort-4.3.19-py2.py3-none-any.whl (42kB)
     |████████████████████████████████| 51kB 3.7MB/s 

(test_isort_python2) timothy@timothy-Desktop:~$ echo "import stuff" | isort -
Traceback (most recent call last):
  File "/home/timothy/test_isort_python2/bin/isort", line 10, in <module>
    sys.exit(main())
  File "/home/timothy/test_isort_python2/local/lib/python2.7/site-packages/isort/main.py", line 343, in main
    SortImports(file_=file_, write_to_stdout=True, **arguments)
  File "/home/timothy/test_isort_python2/local/lib/python2.7/site-packages/isort/isort.py", line 140, in __init__
    file_.seek(0)
IOError: [Errno 29] Illegal seek

I'll work on a hotfix release to fix the Python2 behavior as well shortly.

Thanks!

~TImothy

@timothycrosley timothycrosley added the bug Something isn't working label May 14, 2019
@timothycrosley timothycrosley changed the title Pipe redirection broken since 4.3.13 Pipe redirection broken on Python2.7 since 4.3.13 May 14, 2019
@timothycrosley
Copy link
Member

This has been fixed in isort 4.3.20:

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting isort
  Downloading https://files.pythonhosted.org/packages/1c/d9/bf5848b376e441ff358a14b954476423eeeb8c9b78c10074b7f53ce2918d/isort-4.3.20-py2.py3-none-any.whl (42kB)
     |████████████████████████████████| 51kB 5.6MB/s 
Requirement already satisfied, skipping upgrade: backports.functools-lru-cache; python_version < "3.2" in /home/timothy/test_isort_python2/lib/python2.7/site-packages (from isort) (1.5)
Requirement already satisfied, skipping upgrade: futures; python_version < "3.2" in /home/timothy/test_isort_python2/lib/python2.7/site-packages (from isort) (3.2.0)
Installing collected packages: isort
  Found existing installation: isort 4.3.19
    Uninstalling isort-4.3.19:
      Successfully uninstalled isort-4.3.19
Successfully installed isort-4.3.20

(test_isort_python2) timothy@timothy-Desktop:~/bin$ echo "import      os" | isort -
import os

Thanks!

~Timothy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants