Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pygeoip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pygeoip
Commits
92106a9a
Commit
92106a9a
authored
Feb 22, 2013
by
William Tisäter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make simplified ip2long method work with Python 3.x
parent
72430d4a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
8 deletions
+3
-8
pygeoip/util.py
+3
-8
No files found.
pygeoip/util.py
View file @
92106a9a
...
@@ -20,11 +20,8 @@ You should have received a copy of the GNU Lesser General Public License
...
@@ -20,11 +20,8 @@ You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
along with this program. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
"""
"""
import
struct
import
socket
import
socket
from
array
import
array
import
binascii
from
pygeoip.const
import
PY3
def
ip2long
(
ip
):
def
ip2long
(
ip
):
...
@@ -34,8 +31,6 @@ def ip2long(ip):
...
@@ -34,8 +31,6 @@ def ip2long(ip):
@type ip: str
@type ip: str
"""
"""
try
:
try
:
return
int
(
socket
.
inet_aton
(
ip
)
.
encode
(
'hex'
),
16
)
return
int
(
binascii
.
hexlify
(
socket
.
inet_aton
(
ip
)
),
16
)
except
socket
.
error
:
except
socket
.
error
:
return
int
(
socket
.
inet_pton
(
socket
.
AF_INET6
,
ip
)
.
encode
(
'hex'
),
16
)
return
int
(
binascii
.
hexlify
(
socket
.
inet_pton
(
socket
.
AF_INET6
,
ip
)),
16
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment