Menu

#247 python2 input bug in msys2

2.0
closed
nobody
2016-03-04
2016-03-02
Neroldy
No

Hi
I use MinGW64 bash, and I found the python2 has a little bug. If I write a simple py file:

# -*- coding: utf-8 -*-

world = str(raw_input("hello:"))

print world

and I use python2 example.py to run it, the result is
msys2
it will not display 'hello' first and if i input 'world' and press enter, the 'hello' will display.

but if I use python2 for windows 2.7.10, use cmd to run it, the result is
cmd

Discussion

  • Matthieu Vachon

    Matthieu Vachon - 2016-03-02

    Hi,

    Interactive native programs (all those in /mingw64/bin for example as well as any other program not compiled against msys2-runtime, so every programs outside /usr/bin) has difficulties to correclty work inside mintty. This is because mintty is an emulator of a console and interfactive program sees it as a file based instead of an interactive console.

    I guess your problem is related to this fact. Try using winpty python2 new.py inside mintty. I guess it will solve your problem. If it does, search in the tickets and forums about mintty, interactive, python, you will find lot's more details why winpty is required and how mintty actually works that make it kinda "fail".

    If it does not solve it, I will try to replicate to check if I see the same behavior. But seeing that it works in cmd makes a strong assement that interactivity is the problem.

    If winpty is unrecognized program, simply install it via pacman.

    Regards,
    Matt

     
    • Neroldy

      Neroldy - 2016-03-03

      Thanks~ Problem solved!
      If I use winpty python2 new.py, everything is fine. It's weird, because python3 has no problem.
      Anyway, thank you very much!

       
  • David Macek

    David Macek - 2016-03-04
    • status: open --> closed
     
  • David Macek

    David Macek - 2016-03-04

    Okay, closing.