Now I made some workaround. I created a separate bot user with bot and admin rights in order to avoid "You can't edit page" errors. I don't know where to set the edit permisson for unregistered bots.
With settings in localsettings.php: $wgGroupPermissions['*']['edit'] = true; $wgGroupPermissions['*']['read'] = true; and the dedicated bot user replace.py began to work correctly. It asked me for the password at last. Then I set it back to $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['read'] = false; and the bot previously logged in continued to work.
The mistake was that I should have explicitly run login.py -family:local before beginning botwork. For some reason the bot didn't ask for my password when the wiki was set to private, but it is possible that the reason was a config error in family file which I have corrected meanwhile; I don't know if these are connected or not. So my problem seems to be solved now! :-)
Thanks for the help and sorry for putting unnecessary questions.