This happens with python USE flag enabled. swig is a build-time tool, it shouldn't be runtime-depended upon.
Yes, adding -python to the USE flags makes the error go away and the build succeeds. Is this related to bug #148728 ?
Fixed it myself.