When working with subprocesses, there are many instances when only a specific subset of environment variables are available as per the requirement. So even though $LOGNAME is set by default, gnupg raises a KeyError ( from line #1205) since it cannot find it in the environment it is called from.
Using a random email generator should work in its place, since usually
name_email parameter is never left to be default one. It probably should not be optional at all ( and so need not have a default value altogether).