socket.AF_PACKET doc: proto is *not* in network byte order
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
Documentation
The documentation of socket.AF_PACKET says that the value of proto in the address representation must be in network-byte-order:
https://github.com/python/cpython/blame/v3.12.0a3/Doc/library/socket.rst#L196
Value must be in network-byte-order.
This is incorrect. It is true that the corresponding Linux field sll_protocol is in network byte order (see packet(7)), but Python automatically converts to/from host byte order:
https://github.com/python/cpython/blob/v3.12.0a3/Modules/socketmodule.c#L1483
https://github.com/python/cpython/blob/v3.12.0a3/Modules/socketmodule.c#L2104
Note: This applies to addresses passed to socket.bind() and returned from socket.recvfrom(), but does not apply to the proto parameter of socket.socket() -- Python doesn't automatically convert it, so the user must supply a value in network byte order (when using AF_PACKET). It might be a good idea to document this, e.g. the documentation of ETH_P_ALL could mention that it needs to be converted using socket.htons() before passing to socket.socket().
Bonus typo:
https://github.com/python/cpython/blame/v3.12.0a3/Doc/library/socket.rst#L188
The packets are represented by the tuple
"packets" is inaccurate and should be changed to "addresses" or "sockets".
Linked PRs
- gh-154741
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Abra Doc/library/socket.rst na representação de endereços AF_PACKET e revise os locais citados em Modules/socketmodule.c quanto ao comportamento da ordem dos bytes. Atualize a documentação para distinguir os endereços de bind/recvfrom do parâmetro proto de socket() e corrija a redação de “packets”; está concluído quando as conversões e a terminologia documentadas corresponderem à implementação.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- documentation, networking
- Tipo de issue
- Documentação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 35/100