Skip to content

Fix for reading input while script is in debug with PyCharm running on MacOS #70

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

Conversation

spuliaiev-sfdc
Copy link

I notices that when we use this library with enabled debug with PyCharm on MacOS it hangs while requesting the input.
Does not matter if the script run in the PyCharm internal terminal, iTerm2 terminal or native MacOS terminal app.

@spuliaiev-sfdc
Copy link
Author

Not sure if it need to be extracted into a different file like readchar_mac.py
Please advise @magmax

@spuliaiev-sfdc
Copy link
Author

============================================= test session starts ==============================================
platform darwin -- Python 3.9.9, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /Users/spuliaiev/work/py/python-readchar, configfile: setup.cfg
plugins: cov-3.0.0
collected 9 items

tests/unit/test_key.py ....                                                                              [ 44%]
tests/unit/test_readkey.py .....                                                                         [100%]

---------- coverage: platform darwin, python 3.9.9-final-0 -----------
Name                           Stmts   Miss  Cover   Missing
------------------------------------------------------------
readchar/__init__.py               3      0   100%
readchar/key.py                   59      0   100%
readchar/readchar.py              38     20    47%   8, 11-17, 30-80
readchar/readchar_linux.py        11      7    36%   11-18
readchar/readchar_windows.py      12     12     0%   5-27
------------------------------------------------------------
TOTAL                            123     39    68%


============================================== 9 passed in 0.07s ===============================================

@AndKe
Copy link

AndKe commented Feb 17, 2022

hmm ..if this fixes #51 , please merge.

@spuliaiev-sfdc
Copy link
Author

@AndKe I have no permissions to do that.

Only those with write access to this repository can merge pull requests.

@AndKe
Copy link

AndKe commented Mar 7, 2022

I hoped to get the attention of one of those who can.

@spuliaiev-sfdc
Copy link
Author

@andreatulimiero @magmax @jhonatan-lopes Could you please take a look?

@spuliaiev-sfdc
Copy link
Author

@magmax Would you please take a look?

@jhonatan-lopes
Copy link
Contributor

HI @spuliaiev-sfdc, I'm not a maintainer on this repo. I'm afraid that @magmax is the person you're looking for to review and close the PR.

fleytman added a commit to fleytman/python-readchar that referenced this pull request Jul 27, 2022
add macos pycharm fix magmax#70
fleytman added a commit to fleytman/python-readchar that referenced this pull request Jul 27, 2022
add macos pycharm fix magmax#70
@fleytman fleytman mentioned this pull request Jul 31, 2022
@Cube707
Copy link
Collaborator

Cube707 commented Jul 31, 2022

@spuliaiev-sfdc @AndKe

is anyone still interested in this? is the behaviour still the same with the new v4.0.0 that is currently in pre-release?

@spuliaiev-sfdc
Copy link
Author

spuliaiev-sfdc commented Jul 31, 2022 via email

@Cube707
Copy link
Collaborator

Cube707 commented Jul 31, 2022

OK, so than I need some information to properly understand this.

First of all, is the behavior still the same with the current code from v4.0.0-dev? (should be same but still..)

Than, using sys.stdin.readline(1) instead or read(1) should mean that readchar no waits until enter is pressed instead of imeadiadly processing the keypress.
Is that the case? How is it behaving? Please test with the script found in tests/manual-test.py:

  • What is the original behavior? What happens if you press a, 0, UP, etc..
    • within the PyCharm terminal?
    • whith the nativ Terminal, started as python yourScript.py
  • What is the new behavior with readline(1)? What happens if you press a, 0, UP, etc..
    • within the PyCharm terminal?
    • whith the nativ Terminal, started as python yourScript.py

Screenshots would help a lot 👍

@AndKe
Copy link

AndKe commented Aug 1, 2022

@Cube707 - This is what I am getting now:
Screenshot from 2022-08-01 08-35-06

@Cube707
Copy link
Collaborator

Cube707 commented Aug 1, 2022

@AndKe I can not reproduce. This works as expected on Linux/Windows:

import readchar

k = readchar.readkey()
print(k)

If you don't find an issue on your end, please open a seperate issue with more details.

Just a thought: the prolem might come from your file beeing named readchar.py. This doesn't pose problems for me, but might explain the circular import.

@Cube707
Copy link
Collaborator

Cube707 commented Aug 1, 2022

@AndKe I just found the problem. it is indeed the filename readchar.py. Naming the file the same as a imported module will result in a circular import.

@Cube707
Copy link
Collaborator

Cube707 commented Sep 4, 2022

closing due to inactivity.

@Cube707 Cube707 closed this Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants