GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Bug fix to bad coordinate reading on private IPs. by UmanShahzad · Pull Request #11 · ipinfo/python

Conversation

@UmanShahzad

@UmanShahzad UmanShahzad commented Mar 15, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Closes #10

Fixes an issue where geolocation data isn't available (e.g. for private IPs) and we try to retrieve it by giving an index, without checking if it's valid for the list.

Was able to reproduce the issue in #10 with:

>>> details = handler.getDetails('10.62.100.139')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mslm/dev/ipinfo/python/ipinfo/handler.py", line 53, in getDetails
    lat, lon = coords[0], coords[1]
IndexError: tuple index out of range

After the fix:

>>> details = handler.getDetails('10.62.100.139')
>>> details.all
{'ip': '10.62.100.139', 'bogon': True, 'country_name': None, 'ip_address': IPv4Address('10.62.100.139'), 'latitude': None, 'longitude': None}
>>> details.latitude
>>> details.longitude
>>> details.bogon
True

and for public IPs:

>>> details = handler.getDetails('9.9.9.9')
>>> details.all
{'ip': '9.9.9.9', 'hostname': 'dns.quad9.net', 'city': '', 'region': '', 'country': 'FR', 'loc': '48.8582,2.3387', 'org': 'AS19281 Quad9', 'country_name': 'France', 'ip_address': IPv4Address('9.9.9.9'), 'latitude': '48.8582', 'longitude': '2.3387'}
>>> details.latitude
'48.8582'
>>> details.longitude
'2.3387'
>>> details.loc
'48.8582,2.3387'
>>> details.country
'FR'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Uman Shahzad added 2 commits March 15, 2019 08:54
Uman Shahzad
Bug fix to bad coordinate reading on private IPs.
d1034a8
Uman Shahzad
Bump version.
e9303d8
@UmanShahzad UmanShahzad self-assigned this Mar 15, 2019
@UmanShahzad
UmanShahzad requested review from coderholic and jhtimmins March 15, 2019 03:59
@UmanShahzad UmanShahzad mentioned this pull request Mar 15, 2019
ipinfo return an error (IndexError: tuple index out of range) when details of specific IP address is not available. #10
Closed
@UmanShahzad

UmanShahzad commented Mar 15, 2019

Copy link
Copy Markdown
Contributor Author

@coderholic and/or @jhtimmins can you review/merge/update pypi?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@UmanShahzad
UmanShahzad merged commit 62fef91 into master Mar 17, 2019
@UmanShahzad
UmanShahzad deleted the uman/index-error-fix branch March 17, 2019 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderholic coderholic Awaiting requested review from coderholic
@jhtimmins jhtimmins Awaiting requested review from jhtimmins

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@UmanShahzad UmanShahzad

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

ipinfo return an error (IndexError: tuple index out of range) when details of specific IP address is not available.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@UmanShahzad
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.