timmerk / ipaddr-py

Automatically exported from code.google.com/p/ipaddr-py
0 stars 0 forks source link

constructing an instance doesn't do as much validation on it as str() does #71

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. x = IPAddress('12312312312312312312311111111111111111111')
2. str(x)
3.

What is the expected output? What do you see instead?

Expected: an exception from step 1, seen: exception from step 2

What version of the product are you using? On what operating system?

Today's svn trunk on Linux (also other OSes)

Please provide any additional information below.

It would also be nice if there were a (non-underscore-prefixed) function to 
validate a string as being an IP address, perhaps named "is_valid_ip()" which 
takes a string as argument. 
https://github.com/simplegeo/python-simplegeo-shared/blob/e0ce61e4bfff9aa7870785
4fdcc41a101351cfcc/simplegeo/shared/__init__.py#L241

Original issue reported on code.google.com by zoo...@gmail.com on 22 Dec 2010 at 5:42

GoogleCodeExporter commented 9 years ago
I'll fix this. Thanks for reporting it.

Original comment by pmo...@google.com on 31 Dec 2010 at 9:35

GoogleCodeExporter commented 9 years ago
hrm, I'm not seeing the problem:

-> python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipaddr
>>> ipaddr.IPAddress('12312312312312312312311111111111111111111')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/pmoody/src/ipaddr-py/ipaddr.py", line 78, in IPAddress
    address)
ValueError: '12312312312312312312311111111111111111111' does not appear to be 
an IPv4 or IPv6 address
>>> x = ipaddr.IPAddress('12312312312312312312311111111111111111111')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/pmoody/src/ipaddr-py/ipaddr.py", line 78, in IPAddress
    address)
ValueError: '12312312312312312312311111111111111111111' does not appear to be 
an IPv4 or IPv6 address
>>> str(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined
>>> 

Original comment by pmo...@google.com on 3 Jan 2011 at 2:13

GoogleCodeExporter commented 9 years ago
please re-open with more detail if this is still an issue. I can't reproduce it.

Original comment by pmo...@google.com on 8 Jan 2011 at 2:35