`wm iconbitmap` does not correctly set `hints.icon_pixmap` and `hints.flags` on macOS unless the argument is an empty string. After `wm iconbitmap . hourglass`,
`wm iconbitmap .` returns "hourglass" on Linux and Windows, but an empty string on macOS.

It looks that the `else` block is placed after wrong `if`. Other bug is that the function always returns `TCL_OK` even if `WmSetAttribute()` fails. Comparing with the code on Linux and Windows, I believe that the following patch should fix the issue:

```
Index: macosx/tkMacOSXWm.c
==================================================================
--- macosx/tkMacOSXWm.c
+++ macosx/tkMacOSXWm.c
@@ -2975,18 +2975,19 @@
     }
     if (!TkMacOSXHostToplevelExists(winPtr)) {
        TkMacOSXMakeRealWindowExist(winPtr);
     }
     if (WmSetAttribute(winPtr, TkMacOSXGetNSWindowForDrawable(winPtr->window), interp,
-           WMATT_TITLEPATH, objv[3]) == TCL_OK) {
-       if (!len) {
-           if (wmPtr->hints.icon_pixmap != None) {
-               Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap);
-               wmPtr->hints.icon_pixmap = None;
-           }
-           wmPtr->hints.flags &= ~IconPixmapHint;
-       }
+           WMATT_TITLEPATH, objv[3]) != TCL_OK) {
+       return TCL_ERROR;
+    }
+    if (!len) {
+       if (wmPtr->hints.icon_pixmap != None) {
+           Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap);
+           wmPtr->hints.icon_pixmap = None;
+       }
+       wmPtr->hints.flags &= ~IconPixmapHint;
     } else {
        pixmap = Tk_GetBitmap(interp, (Tk_Window)winPtr, str);
        if (pixmap == None) {
            return TCL_ERROR;
        }
```

I encountered this bug after adding tests for Tkinter

This bug was already known (ticket [](119bb094afd86d959039)), but it was closed without proper fix. So you need also to restore the skipped tests on macOS.