Handle real paths that have other invalid Python identifiers
For me, this manifested as the test failing when my folder
had a hyphen in it. But this should fix it once and for
all.
Signed-off-by: Edward Z. Yang <ezyangfb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/75564
Approved by: https://github.com/suo