Skip to content

Commit b58931f

Browse files
committed
Fix utils.get_random_id
1 parent a5574ee commit b58931f

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

examples/auth_by_code.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44

55
def main():
6-
""" Пример получения access_token из сode после OAuth авторизации на сайте """
6+
""" Пример получения access_token из сode после OAuth авторизации на сайте
7+
"""
78

89
code = '18dczc1337a63427fa'
910
redirect_url = 'http://example.com'

vk_api/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
from __future__ import print_function
1010

11+
import random
12+
1113
import six
12-
import time
1314

1415
try:
1516
import simplejson as json
@@ -37,7 +38,8 @@ def clear_string(s):
3738

3839

3940
def get_random_id():
40-
return int(time.time() * 10000000)
41+
""" Get random int32 number (signed) """
42+
return random.getrandbits(31) * random.choice([-1, 1])
4143

4244

4345
def code_from_number(prefix, postfix, number):

vk_api/vk_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import time
1414

1515
import requests
16+
import six
1617

1718
import jconfig
1819
from .enums import VkUserPermissions

0 commit comments

Comments
 (0)