If the password set for the local DC machine account fails for any reason, an incorrect use of the python 'try: / except: / pass' syntax means that for any error a SAMR password set is attempted, not just the one given by windows 2000.
(In this case there is no SAMR server to set the password on, so it fails)