Wednesday, 5 June 2019

Unable to access value of PYTHONHASHSEED through a module

Trying to see the value of PYTHONHASHSEED by using:

# (this is inside module_1.py)
os.environ['PYTHONHASHSEED'] 

raises a KeyError:

Traceback (most recent call last):
  File "/home/black/Dev/Projects/module_1.py", line 2, in <module>
    os.environ['PYTHONHASHSEED']
  File "/usr/lib/python3.4/os.py", line 631, in __getitem__
    raise KeyError(key) from None
KeyError: 'PYTHONHASHSEED'

Printing the contents of os.environ by

for i in sorted(os.environ):
    print(i)

# prints:
# CLUTTER_IM_MODULE
# COMPIZ_BIN_PATH
# ...
# etc.

reveals that PYTHONHASHSEED is not inside, but I am pretty sure it should have a value since on Python 3.3 and greater, hash randomization is turned on by default.

Question:
Why can't I access its value this way and how can I access it through module_1.py?



from Unable to access value of PYTHONHASHSEED through a module

No comments:

Post a Comment