[Python-checkins] closes bpo-39859: Do not downcast result of hstrerror (GH-18790)

Andy Lester webhook-mailer at python.org
Thu Mar 5 23:43:43 EST 2020


https://github.com/python/cpython/commit/e63117a84ef11083be86db7afb2ac2789491ca09
commit: e63117a84ef11083be86db7afb2ac2789491ca09
branch: master
author: Andy Lester <andy at petdance.com>
committer: GitHub <noreply at github.com>
date: 2020-03-05T20:43:36-08:00
summary:

closes bpo-39859: Do not downcast result of hstrerror (GH-18790)



set_herror builds a string by calling hstrerror but downcasts its return value to char *.  It should be const char *.

Automerge-Triggered-By: @benjaminp

files:
M Modules/socketmodule.c

diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 37b312396f944..2818ac7f20570 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -658,7 +658,7 @@ set_herror(int h_error)
     PyObject *v;
 
 #ifdef HAVE_HSTRERROR
-    v = Py_BuildValue("(is)", h_error, (char *)hstrerror(h_error));
+    v = Py_BuildValue("(is)", h_error, hstrerror(h_error));
 #else
     v = Py_BuildValue("(is)", h_error, "host not found");
 #endif



More information about the Python-checkins mailing list