Yep, that seems to definitely point to the Mac/Apache setup, primarily pointing at Safari (have you tried a different browser after quitting safari? - Preferably one that doesn't use webkit). Another idea is to disable any and all plugins you may have in Safari and if that resolves it, turn them on one at a time to see which one is interfering.
I suspect if your run your script on a different setup you will see it will run without issue.
Hope you have a good Thanksgiving as well. Right now we will likely be staying home as our daughter (2 years old) and my wife both have a stomach bug and we'd hate to pass that around, but if they are feeling any better by tomorrow afternoon we may make our way to see family on Friday.