#35699: DatabaseOperations raise ValueError for valid GenericIPAddressField 
(inet)
value with psycopg3
-------------------------------------+-------------------------------------
     Reporter:  florianvazelle       |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
  psycopg3,GenericIPAddressField     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by florianvazelle:

Old description:

> I move recently to psycopg3, and it's seems that the {{{Inet}}} class
> change to be an alias of {{{ipaddress.ip_address}}} in
> [https://github.com/django/django/blob/main/django/db/backends/postgresql/psycopg_any.py#L12].
> But some valid inet value raise an {{{ValueError}}}, such as:
>

> {{{
> >>> import ipaddress
> >>> ipaddress.ip_address("192.168.1/24")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File
> "/home/florian/.pyenv/versions/3.11.9/lib/python3.11/ipaddress.py", line
> 54, in ip_address
>     raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6
> address')
> ValueError: '192.168.1/24' does not appear to be an IPv4 or IPv6 address
> }}}

New description:

 I move recently to psycopg3, and it's seems that the {{{Inet}}} class
 change to be an alias of {{{ipaddress.ip_address}}} in
 
[https://github.com/django/django/blob/main/django/db/backends/postgresql/psycopg_any.py#L12].
 But some valid inet value raise an {{{ValueError}}}, such as:


 {{{
 >>> import ipaddress
 >>> ipaddress.ip_address("192.168.1/24")
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/home/florian/.pyenv/versions/3.11.9/lib/python3.11/ipaddress.py",
 line 54, in ip_address
     raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6
 address')
 ValueError: '192.168.1/24' does not appear to be an IPv4 or IPv6 address
 }}}

 Reference: [https://www.postgresql.org/docs/current/datatype-net-
 types.html#DATATYPE-INET]

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35699#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070191795ab928-9f3545b5-b598-4124-9e09-986a99184ca8-000000%40eu-central-1.amazonses.com.

Reply via email to