"brew install python3" fails to compile pyexpat
I eventually fixed this by


uninstalling XCode altogether (and relying on the xcode-select command line tools)
cherry-picking this commit into my homebrew-core Taps directory
reinstalling python3