OK.  I changed it to do an exact match of os.path.dirname.  I don't think anything currently in mllib (at least nothing I tried...) elicits a Python stacktrace where a Scala one would be appropriate, but future-proofing isn't bad when it doesn't add code.