It seems that you are using python shell itself. I can also reproduce the behaviour you mention. Both freeze. The same happens if you take a tutorial example form ROOT distribution, e.g. graph.py, add a single line above it:
import matplotlib.pyplot as plt
then try to load it within python3 shell:
exec(open("./graph.py").read())
This also freezes.
But it turns out that all the problems are gone using iPython shell instead of python shell itself. There both of your codes will not freeze and also running:
run graph.py
also won’t freeze.
This means that my problem in the original post seems to have been solved as well.
btw. I am using root6 @6.10.00_2+cocoa+cxx14+cxx17+gcc6+graphviz+gsl+http+minuit2+opengl+python34+roofit+soversion+ssl+tmva+xml and python34 @3.4.6_1+readline on OSX El Capitan.