Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-111201: Support pyrepl on Windows#119559

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ambv merged 70 commits intopython:mainfromDinoV:winrepl
May 31, 2024
Merged

gh-111201: Support pyrepl on Windows#119559

ambv merged 70 commits intopython:mainfromDinoV:winrepl
May 31, 2024

Conversation

DinoV
Copy link
Contributor

@DinoVDinoV commentedMay 25, 2024
edited by github-actionsbot
Loading

This adds Windows support for the new pyrepl.

Support is a mix of vt100 codes, enabling the vt100 codes on the Windows console, and Windows console APIs.

Minimum version required in Windows 10.


📚 Documentation preview 📚:https://cpython-previews--119559.org.readthedocs.build/

stonebig and ambv reacted with hooray emojiAlexWaygood, itamaro, marlenezw, and ambv reacted with heart emoji
DinoVand others added30 commitsMay 16, 2024 18:58
Fix scrolling into input that has scrolled out of the buffer
@lysnikolaoulysnikolaou added OS-windows topic-replRelated to the interactive shell labelsMay 30, 2024
Copy link

@zadjii-msftzadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hey so sorry for coming out of nowhere to leave notes on this. I'm super excited to see this land! I took a spin through this PR just to see if I could find anything egregious in here from a Windows Console standpoint, and nothing really popped out.

I obviously don't really know the pyrepl codebase closely, so my review probably isn't the most valuable. I left my own notes-to-self with a "📝:", mostly just for things I found confusing. Definitely feel free to ignore those.

overall I'd say: I'm super glad y'all aren't going to be usingCOOKED_READ in the console anymore 🎉

info = CONSOLE_SCREEN_BUFFER_INFO()
if not GetConsoleScreenBufferInfo(OutHandle, info):
raise WinError(GetLastError())
return info.dwCursorPosition.X, info.dwCursorPosition.Y

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

📝: This is relative to the origin of the buffer, not of the viewport. is this supposed to be viewport relative in the unix version?


return Event(evt="key", data=key, raw=rec.Event.KeyEvent.uChar.UnicodeChar)

def push_char(self, char: int | bytes) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I suppose I don't totally understand how this is supposed to be used, but there isWriteConsoleInput whichsounds similar

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is specifically aboutpush_char? I don't think it's actually used but it does seem to technically be public API surface. The unix version calls this on inputted chars.


self.__posxy = 0, 0
self.__gone_tall = 0
self.__offset = 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

📝: the unix version also:

  • enables bracketed paste
  • does asmkx (\x1b[?1h)
  • gets the original size (to restore on exit?)

I'm pretty sure the console supported?1h back to RS1, and bracketed paste as ofmicrosoft/terminal#15155 (not sure exactly where in Windows 11 that gets enabled)

You're probably fine continuing to not do them here, but they could maybe get added later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@pablogsal
Copy link
Member

Thanks for your notes@zadjii-msft!

One problem we are still having I think is that resizing the terminal when there are wide Unicode characters such as emojis in many lines doesn't work (the characters don't get resposition after a resize makes the lines warp around and back to normal). This looks like it's a windows only problem because the unix terminal handles that correctly.

I think@ambv or@DinoV may be able to provide more information.

@ambv
Copy link
Contributor

Unicode input and emojis work now. Amazing progress! I'm landing this, we can add further improvements like bracketed paste in future updates. Thanks,@DinoV! ✨ 🍰 ✨

@ambvambv merged commit0d07182 intopython:mainMay 31, 2024
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure⚠️⚠️⚠️

Hi! The buildbotAMD64 FreeBSD14 3.x has failed when building commit0d07182.

What do you need to do:

  1. Don't panic.
  2. Checkthe buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1232/builds/2462) and take a look at the build logs.
  4. Check if the failure is related to this commit (0d07182) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/1232/builds/2462

Failed tests:

  • test_pyrepl

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):  File"/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/test/libregrtest/single.py", line181, in_runtest_env_changed_exc    _load_run_test(result, runtests)~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^  File"/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/test/libregrtest/single.py", line138, in_load_run_test    regrtest_runner(result, test_func, runtests)~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/test/libregrtest/single.py", line91, inregrtest_runner    test_result= test_func()  File"/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/test/libregrtest/single.py", line135, intest_funcreturn run_unittest(test_mod)  File"/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/test/libregrtest/single.py", line35, inrun_unittestraiseException("errors while loading tests")Exception:errors while loading testsTraceback (most recent call last):  File"/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/unittest/loader.py", line396, in_find_test_path    module=self._get_module_from_name(name)  File"/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/unittest/loader.py", line339, in_get_module_from_name__import__(name)~~~~~~~~~~^^^^^^  File"/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/test/test_pyrepl/test_windows_console.py", line5, in<module>from _pyrepl.windows_consoleimport (...<5 lines>...    )  File"/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/_pyrepl/windows_console.py", line30, in<module>import ctypes  File"/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/ctypes/__init__.py", line8, in<module>from _ctypesimport Union, Structure, ArrayModuleNotFoundError:No module named '_ctypes'

@ambv
Copy link
Contributor

Buildbot failure related. Fixing now.

@miss-islington-app
Copy link

Thanks@DinoV for the PR, and@ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks@DinoV for the PR, and@ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 31, 2024
(cherry picked from commit0d07182)Co-authored-by: Dino Viehland <dinoviehland@gmail.com>Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>Co-authored-by: Łukasz Langa <lukasz@langa.pl>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 31, 2024
(cherry picked from commit0d07182)Co-authored-by: Dino Viehland <dinoviehland@gmail.com>Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>Co-authored-by: Łukasz Langa <lukasz@langa.pl>
@bedevere-app
Copy link

GH-119850 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelMay 31, 2024
@zadjii-msft
Copy link

zadjii-msft commentedMay 31, 2024
edited
Loading

One problem we are still having I think is that resizing the terminal when there are wide Unicode characters such as emojis in many lines doesn't work (the characters don't get resposition after a resize makes the lines warp around and back to normal). This looks like it's a windows only problem because the unix terminal handles that correctly

Oh that for sure sounds like aus bug. We've been making pretty dramatic improvements to the unicode / emoji support over the last couple years, so I'm guessing you're seeing different behavior even depending on what version of Windows & the Terminal you're running.

If you've got specific bugs on your tracker for those, point me at 'em, and I can get the team to double check them☺️


EDIT: derp I only read one mail, then replied to it before I saw#119559 (comment).

if sys.platform != "win32":
CAN_USE_PYREPL = True
else:
CAN_USE_PYREPL = sys.getwindowsversion().build >= 10586 # Windows 10 TH2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This merged as-is which is OK, but I wanted to chip in...

There is aminimal risk of cutting out terminals that would support pyrepl on earlier versions of Windows. The "most correct" (also most soapboxy, sorry!) way to determine support for this is to just try to setENABLE_VIRTUAL_TERMINAL_PROCESSING and only fall back to basic console APIs if it fails. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@DHowett sounds like an improvement we can still make! Care to PR this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I can try - at the very least, it would be a great opportunity for me to learn how to build and deploy Python 🙂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

ambv added a commit that referenced this pull requestMay 31, 2024
(cherry picked from commit0d07182)Co-authored-by: Dino Viehland <dinoviehland@gmail.com>Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>Co-authored-by: Łukasz Langa <lukasz@langa.pl>
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull requestJul 11, 2024
Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>Co-authored-by: Łukasz Langa <lukasz@langa.pl>
estyxx pushed a commit to estyxx/cpython that referenced this pull requestJul 17, 2024
Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@DHowettDHowettDHowett left review comments

@tonybaloneytonybaloneytonybaloney left review comments

@AlexWaygoodAlexWaygoodAlexWaygood left review comments

@zadjii-msftzadjii-msftzadjii-msft approved these changes

@Jose1654Jose1654Jose1654 approved these changes

@pablogsalpablogsalAwaiting requested review from pablogsalpablogsal is a code owner

@lysnikolaoulysnikolaouAwaiting requested review from lysnikolaoulysnikolaou is a code owner

@ambvambvAwaiting requested review from ambvambv is a code owner

Assignees
No one assigned
Labels
awaiting core reviewOS-windowstopic-replRelated to the interactive shell
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

10 participants
@DinoV@AlexWaygood@pablogsal@ambv@bedevere-bot@zadjii-msft@DHowett@tonybaloney@Jose1654@lysnikolaou

[8]ページ先頭

©2009-2025 Movatter.jp