[issue46646] `address` arg can be `bytes` for `ip_*` functions in `ipaddress` module

2022-02-12 Thread Éric Araujo

Éric Araujo  added the comment:

Can you dig more to find if the problem is in the code or in the doc?
The PEP to add ipaddress should specify this.

--
nosy: +eric.araujo, pmoody

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46646] `address` arg can be `bytes` for `ip_*` functions in `ipaddress` module

2022-02-04 Thread Nikita Sobolev


Change by Nikita Sobolev :


--
keywords: +patch
pull_requests: +29317
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31139

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46646] `address` arg can be `bytes` for `ip_*` functions in `ipaddress` module

2022-02-04 Thread Nikita Sobolev


New submission from Nikita Sobolev :

Right now the docs say:

> ipaddress.ip_interface(address)
> Return an IPv4Interface or IPv6Interface object depending on the IP address 
> passed as argument. **address is a string or integer** representing the IP 
> address. Either IPv4 or IPv6 addresses may be supplied; integers less than 
> 2**32 will be considered to be IPv4 by default. A ValueError is raised if 
> address does not represent a valid IPv4 or IPv6 address.

Note the `address is a string or integer` part.

But, this is not true. Counter example:

```
>>> import ipaddress
>>> ipaddress.ip_interface(b'')
IPv4Interface('48.48.48.48/32')
>>> ipaddress.ip_interface(b'')
IPv4Interface('49.49.49.49/32')
```

So, packed version that accepts `bytes`, should be also mentioned.

For `ip_address` types are not mentioned:

> ipaddress.ip_address(address)
> Return an IPv4Address or IPv6Address object depending on the IP address 
> passed as argument. Either IPv4 or IPv6 addresses may be supplied; integers 
> less than 2**32 will be considered to be IPv4 by default. A ValueError is 
> raised if address does not represent a valid IPv4 or IPv6 address.

I will send a PR with proposed changes.

--
assignee: docs@python
components: Documentation
messages: 412562
nosy: docs@python, sobolevn
priority: normal
severity: normal
status: open
title: `address` arg can be `bytes` for `ip_*` functions in `ipaddress` module
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com