Ensure that the fix for #17269 also works on OSX 10.4

AI_NUMERICSERV isn't defined on OSX 10.4.
Issue #18180: Fix ref leak in _PyImport_GetDynLoadWindows().
Issue #18174: Fix fd leaks in tests.
remove MAX_MAXCHAR because it's unsafe for computing maximum codepoitn value (see #18183)