it fixes the issue getlogin is an unsafe and deprecated way of determining the logged-in user. It's probably trying to open a record of logged-in users, perhaps utmp or something. The correct way to determine the user you're running as (which might not be the same as the logged-in user, but is almost always better to use anyway) is getpwuid(getuid()).
Attempt to rename file in Documents directory has error "file:/..."
help you fix your problem The NSString path manipulation methods like stringByAppendingPathComponent expects file paths not URLs. It will remove double slashes as this is not a valid file path (although it is a valid URL).
os.mkdir() returns error "FileNotFoundError: [Errno 2] No such file or directory"