Skip to content

Commit ac3765c

Browse files
authored
use getpass instead of os.getlogin() (tinygrad#8972)
1 parent 308516e commit ac3765c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tinygrad/helpers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
import os, functools, platform, time, re, contextlib, operator, hashlib, pickle, sqlite3, tempfile, pathlib, string, ctypes, sys, gzip
2+
import os, functools, platform, time, re, contextlib, operator, hashlib, pickle, sqlite3, tempfile, pathlib, string, ctypes, sys, gzip, getpass
33
import urllib.request, subprocess, shutil, math, contextvars, types, copyreg, inspect, importlib
44
from dataclasses import dataclass
55
from typing import Union, ClassVar, Optional, Iterable, Any, TypeVar, Callable, Sequence, TypeGuard, Iterator, Generic
@@ -79,7 +79,7 @@ def to_function_name(s:str): return ''.join([c if c in (string.ascii_letters+str
7979
@functools.lru_cache(maxsize=None)
8080
def getenv(key:str, default=0): return type(default)(os.getenv(key, default))
8181
def temp(x:str, append_user:bool=False) -> str:
82-
return (pathlib.Path(tempfile.gettempdir()) / (f"{x}.{os.getenv('USERNAME', os.getlogin())}" if append_user else x)).as_posix()
82+
return (pathlib.Path(tempfile.gettempdir()) / (f"{x}.{getpass.getuser()}" if append_user else x)).as_posix()
8383

8484
class Context(contextlib.ContextDecorator):
8585
def __init__(self, **kwargs): self.kwargs = kwargs

0 commit comments

Comments
 (0)