bpo-42393: Raise OverflowError iso. DeprecationWarning on overflow in socket.ntohs and socket.htons (GH-23980)
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index 4511ff9..2255b82 100755
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -907,11 +907,9 @@
where the host byte order is the same as network byte order, this is a no-op;
otherwise, it performs a 2-byte swap operation.
- .. deprecated:: 3.7
- In case *x* does not fit in 16-bit unsigned integer, but does fit in a
- positive C int, it is silently truncated to 16-bit unsigned integer.
- This silent truncation feature is deprecated, and will raise an
- exception in future versions of Python.
+ .. versionchanged:: 3.10
+ Raises :exc:`OverflowError` if *x* does not fit in a 16-bit unsigned
+ integer.
.. function:: htonl(x)
@@ -927,11 +925,9 @@
where the host byte order is the same as network byte order, this is a no-op;
otherwise, it performs a 2-byte swap operation.
- .. deprecated:: 3.7
- In case *x* does not fit in 16-bit unsigned integer, but does fit in a
- positive C int, it is silently truncated to 16-bit unsigned integer.
- This silent truncation feature is deprecated, and will raise an
- exception in future versions of Python.
+ .. versionchanged:: 3.10
+ Raises :exc:`OverflowError` if *x* does not fit in a 16-bit unsigned
+ integer.
.. function:: inet_aton(ip_string)
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index db34b33..aa547ff 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -537,6 +537,12 @@
silently in Python 3.9.
(Contributed by Ken Jin in :issue:`42195`.)
+* :meth:`socket.htons` and :meth:`socket.ntohs` now raise :exc:`OverflowError`
+ instead of :exc:`DeprecationWarning` if the given parameter will not fit in
+ a 16-bit unsigned integer.
+ (Contributed by Erlend E. Aasland in :issue:`42393`.)
+
+
CPython bytecode changes
========================