Skip to content
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

IDLE: Colorizer and output tests hang on macOS #88496

Closed
terryjreedy opened this issue Jun 7, 2021 · 7 comments
Closed

IDLE: Colorizer and output tests hang on macOS #88496

terryjreedy opened this issue Jun 7, 2021 · 7 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes OS-mac tests Tests in the Lib/test dir topic-IDLE

Comments

@terryjreedy
Copy link
Member

terryjreedy commented Jun 7, 2021

BPO 44330
Nosy @terryjreedy, @taleinat, @ned-deily

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-06-07.01:41:11.947>
labels = ['3.9', '3.10', '3.11']
title = 'IDLE: Colorizer and output tests hang on macOS'
updated_at = <Date 2021-06-07.22:11:14.604>
user = 'https://github.com/terryjreedy'

bugs.python.org fields:

activity = <Date 2021-06-07.22:11:14.604>
actor = 'terry.reedy'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2021-06-07.01:41:11.947>
creator = 'terry.reedy'
dependencies = []
files = []
hgrepos = []
issue_num = 44330
keywords = []
message_count = 3.0
messages = ['395239', '395285', '395290']
nosy_count = 3.0
nosy_names = ['terry.reedy', 'taleinat', 'ned.deily']
pr_nums = []
priority = 'critical'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue44330'
versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

Linked PRs

@terryjreedy
Copy link
Member Author

Ned, have you seen or heard anything about tkinter/tk8.6.11 freezing on macOS? It is happening in many places.

On my MacBook, python3.9 -m test -ugui -v test_idle runs OK in about 10 seconds. With installed python3.10.0b2, it runs test_colorizer ColorCongigTest, ColorDelagatorInstantionTest, and ColorDelagatorTest.test_LoadTagDefs. It hangs on test_case_soft_keyword, which is new in 3.10 for the new match statement soft keywords. With added skips, it hangs on
test_def_statement
test_incremental_editing
test_match_soft_keyword
test_recolorize_main
test_removecolors
and then test_colorizer passes.

At this point, I thought the problem was the fancy new test methods and helpers. But running test_idle again, test_outwin.OutputWindowTest.test_goto_file_line (line 105) hangs displaying a blank window. The test writes something at 115 which did not appear. However, debug prints indicate that it is the 2nd write, about 121, that does not return. The write method just inserts into the text widget. Nothing apparently fancy. The failure is deterministic (over 10 times). In 3.9.5, the same test and all of test_idle ran OK 3 times.

Adding .update() and .update_idletasks() before the write did nothing. Making this test method fail before the write, let the test continue until it hung in test_write.

The problem seems to be in the test environment. Tests of match, case, and _ in Shell looked corrected. Grepping idlelib for 'tkinter' returned 222 hits and multiple gotos for different files and lines within a file worked normally.

@terryjreedy terryjreedy added 3.10 only security fixes 3.11 only security fixes labels Jun 7, 2021
@terryjreedy terryjreedy changed the title IDLE: Colorizer test hangs on macOS IDLE: Colorizer and output tests hang on macOS Jun 7, 2021
@terryjreedy terryjreedy changed the title IDLE: Colorizer test hangs on macOS IDLE: Colorizer and output tests hang on macOS Jun 7, 2021
@ned-deily
Copy link
Member

I can reproduce test_idle hanging on all of the current python.org macOS universal2 variants (3.8.10, 3.9.5, 3.10.0b2) which use Tk 8.6.11 but not with the legacy 10.9 variants for 3.8.10 and 3.9.5 which use Tk 8.6.8. I've tried it on a few older systems, as far back as 10.9, and they all seem to hang the same way. For 3.9.5 (and 3.8.10 now in security-fix mode), the first hang seems to be in test_removecolors which I need to Ctrl-C out of:

/usr/local/bin/python3.9 -m test -v -uall test_idle
[...]
test_insert (idlelib.idle_test.test_colorizer.ColorDelegatorTest) ... ok
test_notify_range (idlelib.idle_test.test_colorizer.ColorDelegatorTest) ... ok
test_recolorize (idlelib.idle_test.test_colorizer.ColorDelegatorTest) ... ok
test_recolorize_main (idlelib.idle_test.test_colorizer.ColorDelegatorTest) ... ok
test_removecolors (idlelib.idle_test.test_colorizer.ColorDelegatorTest) ...

I also see the hangs with current MacPorts Pythons linked with their build of Tk 8.6.11.

@ned-deily ned-deily added 3.9 only security fixes labels Jun 7, 2021
@terryjreedy
Copy link
Member Author

Yes, I have the 'old' 3.9.5. In IDLE, ^C does not break the hang, but Restart Shell does. As I expected, I had to skip test_outwin's test_write and test_writelines to stop that test hanging.

Next failure: test_sidebar.LineNumbersTest ends with test_toggle_linenumbering ... OK. That is the last test method and the hang is in tearDownClass "cls.root.update()". Changing to .update_idletasks() fixes this. I believe that the latter is what we usually use before destroying root. But still, update should not crash. At worst, a TclError.

With this fix, test_idle passes. So do test_tcl and test_ttk_textonly. Test_tk and test_ttk_guionly each have 1 failure. (For me) The test suite as a whole is a mess, with multiple Python-crashed message boxes.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@erlend-aasland erlend-aasland added topic-IDLE tests Tests in the Lib/test dir labels Jul 25, 2022
@chrstphrchvz
Copy link
Contributor

chrstphrchvz commented Apr 25, 2023

I also encountered the hang in test_case_soft_keyword. I believe it occurs during this update():

self.update()

Can this update() be replaced with update_idletasks()? I find that doing so allows the test to pass on Aqua. Tcl/Tk has generally discouraged using update, at least where update idletasks will suffice. And update on Tk Aqua (Cocoa) has been prone to issues.

@chrstphrchvz
Copy link
Contributor

I also encounter the hang in test_outwin.OutputWindowTest.test_goto_file_line due to this update:

self.text.update()

Changing it to update_idletasks() allows this test to pass here as well.

@terryjreedy
Copy link
Member Author

terryjreedy commented Apr 26, 2023

Both of those .update() calls are from the original 2000 idlelib commit. There are 13 others (not all from 2000 ;-). (Possibly one or two from a locally defined update function.) I am not sure that I am completely clear on when to use which. Feel free to check others.

The output update is there to slow down the display to make each line visible and then scroll. When recursively grepping 'editor' the 295 lines take several seconds instead displaying the entire output in a fraction of a second. CommandPrompt displays 300 lines in about the same time. Maybe I will delete instead of replace, or consider for later.

The colorizer update() is preceded by this:

                if not ok:
                    # We're in an inconsistent state, and the call to
                    # update may tell us to stop.  It may also change
                    # the correct value for "next" (since this is a
                    # line.col string, not a true mark).  So leave a
                    # crumb telling the next invocation to resume here
                    # in case update tells us to leave.
                    self.tag_add("TODO", next)

How? No evidence of the claims, no test case to see if still true 23 years later. It turns out that either update causes color to be erased after a font face, size, or boldness changes. Comes back faster with update_idletasks. With neither, I don't see it disappear. I need to test behavior while typing or scrolling, but too late today.

(Note to myself: branch idletasks.)

terryjreedy added a commit to terryjreedy/cpython that referenced this issue Apr 30, 2023
Replace widget.update() with widget.update_idletasks in two places.
terryjreedy added a commit that referenced this issue May 1, 2023
Replace widget.update() with widget.update_idletasks in two places.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 1, 2023
Replace widget.update() with widget.update_idletasks in two places.
(cherry picked from commit 4b27972)

Co-authored-by: Terry Jan Reedy <[email protected]>
terryjreedy added a commit that referenced this issue May 1, 2023
gh-88496: Fix IDLE test hang on macOS (GH-104025)

Replace widget.update() with widget.update_idletasks in two places.
(cherry picked from commit 4b27972)

Co-authored-by: Terry Jan Reedy <[email protected]>
@terryjreedy
Copy link
Member Author

More is needed for test_idle to pass on my 'Air' with Catalina. I added another '_idletasks' in test_sidebar to fix another hang, but an 'is' test is failing in test_mousewheel. I may just skip on mac. (branch update2.)

carljm added a commit to carljm/cpython that referenced this issue May 1, 2023
* main: (26 commits)
  pythongh-104028: Reduce object creation while calling callback function from gc (pythongh-104030)
  pythongh-104036: Fix direct invocation of test_typing (python#104037)
  pythongh-102213: Optimize the performance of `__getattr__` (pythonGH-103761)
  pythongh-103895: Improve how invalid `Exception.__notes__` are displayed (python#103897)
  Adjust expression from `==` to `!=` in alignment with the meaning of the paragraph. (pythonGH-104021)
  pythongh-88496: Fix IDLE test hang on macOS (python#104025)
  Improve int test coverage (python#104024)
  pythongh-88773: Added teleport method to Turtle library (python#103974)
  pythongh-104015: Fix direct invocation of `test_dataclasses` (python#104017)
  pythongh-104012: Ensure test_calendar.CalendarTestCase.test_deprecation_warning consistently passes (python#104014)
  pythongh-103977: compile re expressions in platform.py only if required (python#103981)
  pythongh-98003: Inline call frames for CALL_FUNCTION_EX (pythonGH-98004)
  Replace Netlify with Read the Docs build previews (python#103843)
  Update name in acknowledgements and add mailmap (python#103696)
  pythongh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (python#103927)
  Remove non-existing tools from Sundry skiplist (python#103991)
  pythongh-103793: Defer formatting task name (python#103767)
  pythongh-87092: change assembler to use instruction sequence instead of CFG (python#103933)
  pythongh-103636: issue warning for deprecated calendar constants (python#103833)
  Various small fixes to dis docs (python#103923)
  ...
carljm added a commit to carljm/cpython that referenced this issue May 1, 2023
* main: (463 commits)
  pythongh-104057: Fix direct invocation of test_super (python#104064)
  pythongh-87092: Expose assembler to unit tests (python#103988)
  pythongh-97696: asyncio eager tasks factory (python#102853)
  pythongh-84436: Immortalize in _PyStructSequence_InitBuiltinWithFlags() (pythongh-104054)
  pythongh-104057: Fix direct invocation of test_module (pythonGH-104059)
  pythongh-100458: Clarify Enum.__format__() change of mixed-in types in the whatsnew/3.11.rst (pythonGH-100387)
  pythongh-104018: disallow "z" format specifier in %-format of byte strings (pythonGH-104033)
  pythongh-104016: Fixed off by 1 error in f string tokenizer (python#104047)
  pythonGH-103629: Update Unpack's repr in compliance with PEP 692 (python#104048)
  pythongh-102799: replace sys.exc_info by sys.exception in inspect and traceback modules (python#104032)
  Fix typo in "expected" word in few source files (python#104034)
  pythongh-103824: fix use-after-free error in Parser/tokenizer.c (python#103993)
  pythongh-104035: Do not ignore user-defined `__{get,set}state__` in slotted frozen dataclasses (python#104041)
  pythongh-104028: Reduce object creation while calling callback function from gc (pythongh-104030)
  pythongh-104036: Fix direct invocation of test_typing (python#104037)
  pythongh-102213: Optimize the performance of `__getattr__` (pythonGH-103761)
  pythongh-103895: Improve how invalid `Exception.__notes__` are displayed (python#103897)
  Adjust expression from `==` to `!=` in alignment with the meaning of the paragraph. (pythonGH-104021)
  pythongh-88496: Fix IDLE test hang on macOS (python#104025)
  Improve int test coverage (python#104024)
  ...
terryjreedy added a commit to terryjreedy/cpython that referenced this issue May 2, 2023
Needed for Catalina: test_sidebar add 'idletasks' and skip assert.
terryjreedy added a commit that referenced this issue May 2, 2023
Needed for Catalina: test_sidebar add 'idletasks' and skip assert.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 2, 2023
Needed for Catalina: test_sidebar add 'idletasks' and skip assert.
(cherry picked from commit 690df4c)

Co-authored-by: Terry Jan Reedy <[email protected]>
terryjreedy added a commit that referenced this issue May 2, 2023
gh-88496: IDLE - fix another test on macOS (GH-104075)

Needed for Catalina: test_sidebar add 'idletasks' and skip assert.
(cherry picked from commit 690df4c)

Co-authored-by: Terry Jan Reedy <[email protected]>
carljm added a commit to carljm/cpython that referenced this issue May 2, 2023
* main:
  pythongh-103822: [Calendar] change return value to enum for day and month APIs (pythonGH-103827)
  pythongh-65022: Fix description of tuple return value in copyreg (python#103892)
  pythonGH-103525: Improve exception message from `pathlib.PurePath()` (pythonGH-103526)
  pythongh-84436: Add integration C API tests for immortal objects (pythongh-103962)
  pythongh-103743: Add PyUnstable_Object_GC_NewWithExtraData (pythonGH-103744)
  pythongh-102997: Update Windows installer to SQLite 3.41.2. (python#102999)
  pythonGH-103484: Fix redirected permanently URLs (python#104001)
  Improve assert_type phrasing (python#104081)
  pythongh-102997: Update macOS installer to SQLite 3.41.2. (pythonGH-102998)
  pythonGH-103472: close response in HTTPConnection._tunnel (python#103473)
  pythongh-88496: IDLE - fix another test on macOS (python#104075)
  pythongh-94673: Hide Objects in PyTypeObject Behind Accessors (pythongh-104074)
  pythongh-94673: Properly Initialize and Finalize Static Builtin Types for Each Interpreter (pythongh-104072)
  pythongh-104016: Skip test for deeply neste f-strings on wasi (python#104071)
carljm added a commit to carljm/cpython that referenced this issue May 2, 2023
* main: (760 commits)
  pythonGH-104102: Optimize `pathlib.Path.glob()` handling of `../` pattern segments (pythonGH-104103)
  pythonGH-104104: Optimize `pathlib.Path.glob()` by avoiding repeated calls to `os.path.normcase()` (pythonGH-104105)
  pythongh-103822: [Calendar] change return value to enum for day and month APIs (pythonGH-103827)
  pythongh-65022: Fix description of tuple return value in copyreg (python#103892)
  pythonGH-103525: Improve exception message from `pathlib.PurePath()` (pythonGH-103526)
  pythongh-84436: Add integration C API tests for immortal objects (pythongh-103962)
  pythongh-103743: Add PyUnstable_Object_GC_NewWithExtraData (pythonGH-103744)
  pythongh-102997: Update Windows installer to SQLite 3.41.2. (python#102999)
  pythonGH-103484: Fix redirected permanently URLs (python#104001)
  Improve assert_type phrasing (python#104081)
  pythongh-102997: Update macOS installer to SQLite 3.41.2. (pythonGH-102998)
  pythonGH-103472: close response in HTTPConnection._tunnel (python#103473)
  pythongh-88496: IDLE - fix another test on macOS (python#104075)
  pythongh-94673: Hide Objects in PyTypeObject Behind Accessors (pythongh-104074)
  pythongh-94673: Properly Initialize and Finalize Static Builtin Types for Each Interpreter (pythongh-104072)
  pythongh-104016: Skip test for deeply neste f-strings on wasi (python#104071)
  pythongh-104057: Fix direct invocation of test_super (python#104064)
  pythongh-87092: Expose assembler to unit tests (python#103988)
  pythongh-97696: asyncio eager tasks factory (python#102853)
  pythongh-84436: Immortalize in _PyStructSequence_InitBuiltinWithFlags() (pythongh-104054)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes OS-mac tests Tests in the Lib/test dir topic-IDLE
Projects
Status: Done
Development

No branches or pull requests

4 participants