Discover fixes

Backport the fix for discovery in packages from Python bugtracker.
Can you please update the comment to say "Uncomment this when issue 16662 has been fixed in upstream Python."?