language/python: don't die in reads_brewed_pth_files?

Addresses #33900. Anything that causes an exception here is probably a symptom of a larger problem but it's probably bad for the doctor to die. :syringe:

The reported error was:

    Error: undefined method close! for nil:NilClass
    /usr/local/Library/Homebrew/extend/pathname.rb:129:in ensure in atomic_write
    ...

Is there a better way to catch this?