Don't take Wikipedia as an authority on this (or anything). There is more to it. There are different rules for "nearby" foreign ports and distant foreign ports, lot of other stuff. I suggest you read this excellent article
written by a friend of mine. It is from 1999 but still provides a great overview of the law and it's caveats.