Skip to content

Commit a8b52c7

Browse files
committed
Python 2/3 compatibility
- thread vs _thread - future print_function
1 parent 614b89f commit a8b52c7

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Diff for: lib/google/geocode/geocode.py

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
701 1st Avenue, Sunnyvale, CA 94089, USA
1616
"""
1717

18+
# Future Imports
19+
from __future__ import print_function
20+
1821
# Python Standard Library Imports
1922
import getopt
2023
import json

Diff for: middleware/classes.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Python Standard Library Imports
22
import datetime
33
import re
4+
import sys
45

56
# Django Imports
67
from django.conf import settings
@@ -14,7 +15,12 @@
1415
from htk.utils import htk_setting
1516
from htk.utils.request import is_allowed_host
1617

17-
import _thread
18+
19+
is_py2 = sys.version[0] == '2'
20+
if is_py2:
21+
import thread as _thread
22+
else:
23+
import _thread
1824

1925

2026
class GlobalRequestMiddleware(MiddlewareMixin):

Diff for: monitor.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Future Imports
2+
from __future__ import print_function
3+
14
# Python Standard Library Imports
25
import atexit
36
import os

0 commit comments

Comments
 (0)