Docs: socket.htons() and friends raise ValueError for negative input since 3.14
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Documentación
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- documentation
Línea de trabajo
Lee Doc/library/socket.rst y revisa la documentación de htons(), ntohs(), htonl() y ntohl(). Confirma el cambio descrito en las excepciones con el ejemplo o las pruebas proporcionadas y, después, documenta el comportamiento de 3.14 para las cuatro funciones o en las notas de migración de 3.14. La tarea estará lista cuando la documentación distinga entre ValueError para entradas negativas y OverflowError para valores demasiado grandes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Documentation
Doc/library/socket.rst, htons() (and ntohs()):
.. versionchanged:: 3.10
Raises OverflowError if x does not fit in a 16-bit unsigned integer.
Since 3.14 a negative argument raises ValueError ("Cannot convert negative
int"); only too-large values still raise OverflowError. htonl()/ntohl() behave the same way:
import socket
for f in (socket.htons, socket.ntohs, socket.htonl, socket.ntohl):
for v in (-1, 1 << 40):
try:
f(v)
except Exception as e:
print(f.__name__, v, type(e).__name__)
| Version | -1 |
1 << 40 |
|---|---|---|
| 3.13 | OverflowError | OverflowError |
| 3.14 / 3.15 | ValueError | OverflowError |
This probably came with gh-132987 (__index__() support in the socket module).
It may be intended, but it is not documented, and except OverflowError
code written against the 3.10 note no longer catches negative input.
Suggested fix: add a versionchanged:: 3.14 note to all four functions, or
mention it in What's New in 3.14 (Porting).
Linked PRs
- gh-159047
- Lenguaje dominante
- Python
- Estrellas
- 77.6k
- Forks
- 37.6k
- Merge medio
- 1 d 20 h
- PR fusionados (30 d)
- 593
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python/cpython
-
docs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
python/cpython#159061 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
3.14 3.15 3.16 stdlib type-bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
python/cpython#159044 · 7 comentarios ·
Los mantenedores suelen responder en 1 día
-
A minor problem with the section "6.10.2. Membership test operations" from the language reference.Abiertodocs pending
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
python/cpython#159034 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
stdlib topic-profiling type-bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
Todos los issues de python/cpython
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
EvaluationSuite.run fails with default args_for_task and mutates supplied kwargsPosiblemente ocupada @ktz03 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
huggingface/evaluate#825 ·
Los mantenedores suelen responder en 1 día
-
Add `django-upgrade` to the CIAbiertodependencies feature github_actions good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
wemake-services/wemake-django-template#3149 ·
Los mantenedores suelen responder en 1 día
-
[request] vsg/1.1.16Abiertoupstream update
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
conan-io/conan-center-index#31142 ·
Los mantenedores suelen responder en 1 día
-
area:core bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día