Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Only import secrets when available
Browse files Browse the repository at this point in the history
secrets got introduced in python 3.6 so this class is not available
in 3.5 and before.

This now checks for the current running version and only tries using
secrets if the version is 3.6 or above

Signed-Off-By: Matthias Kesler <[email protected]>
  • Loading branch information
krombel committed Jul 30, 2018
1 parent e9b2d04 commit 254e826
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.d/3626.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Only import secrets when available (fix for py < 3.6)
7 changes: 3 additions & 4 deletions synapse/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@
used in Python 3.6, and the API emulated in Python 2.7.
"""

import six
import sys

if six.PY3:
# secrets is available since python 3.6
if sys.version_info[0:2] >= (3, 6):
import secrets

def Secrets():
return secrets


else:

import os
import binascii

Expand Down

0 comments on commit 254e826

Please sign in to comment.