Branch merge
diff --git a/Doc/ACKS.txt b/Doc/ACKS.txt
index d79d5cc..ec9efb0 100644
--- a/Doc/ACKS.txt
+++ b/Doc/ACKS.txt
@@ -219,6 +219,7 @@
* Collin Winter
* Blake Winton
* Dan Wolfe
+ * Adam Woodbeck
* Steven Work
* Thomas Wouters
* Ka-Ping Yee
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index c5010bb..3fce587 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -989,3 +989,22 @@
# disabled promiscuous mode
s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)
+
+
+Running an example several times with too small delay between executions, could
+lead to this error::
+
+ socket.error: [Errno 98] Address already in use
+
+This is because the previous execution has left the socket in a ``TIME_WAIT``
+state, and can't be immediately reused.
+
+There is a :mod:`socket` flag to set, in order to prevent this,
+:data:`socket.SO_REUSEADDR`::
+
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ s.bind((HOST, PORT))
+
+the :data:`SO_REUSEADDR` flag tells the kernel to reuse a local socket in
+``TIME_WAIT`` state, without waiting for its natural timeout to expire.
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index 77cfb26..a84bae0 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -239,6 +239,14 @@
pass
self.assertRaises(TypeError, setattr, POINT, "_fields_", [("x", 1), ("y", 2)])
+ def test_invalid_name(self):
+ # field name must be string
+ def declare_with_name(name):
+ class S(Structure):
+ _fields_ = [(name, c_int)]
+
+ self.assertRaises(TypeError, declare_with_name, u"x\xe9")
+
def test_intarray_fields(self):
class SomeInts(Structure):
_fields_ = [("a", c_int * 4)]
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 112b419..6828eab 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2264,17 +2264,11 @@
try:
g = grp.getgrnam(tarinfo.gname)[2]
except KeyError:
- try:
- g = grp.getgrgid(tarinfo.gid)[2]
- except KeyError:
- g = os.getgid()
+ g = tarinfo.gid
try:
u = pwd.getpwnam(tarinfo.uname)[2]
except KeyError:
- try:
- u = pwd.getpwuid(tarinfo.uid)[2]
- except KeyError:
- u = os.getuid()
+ u = tarinfo.uid
try:
if tarinfo.issym() and hasattr(os, "lchown"):
os.lchown(targetpath, u, g)
diff --git a/Misc/NEWS b/Misc/NEWS
index 0778cad..2b6a890 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -39,10 +39,15 @@
Library
-------
-
+
- Issue #8286: The distutils command sdist will print a warning message instead
of crashing when an invalid path is given in the manifest template.
+- Issue #12841: tarfile unnecessarily checked the existence of numerical user
+ and group ids on extraction. If one of them did not exist the respective id
+ of the current user (i.e. root) was used for the file and ownership
+ information was lost.
+
- Issue #10946: The distutils commands bdist_dumb, bdist_wininst and bdist_msi
now respect a --skip-build option given to bdist.
@@ -183,6 +188,9 @@
Extension Modules
-----------------
+- Issue #12764: Fix a crash in ctypes when the name of a Structure field is not
+ a string.
+
- Issue #9651: Fix a crash when ctypes.create_string_buffer(0) was passed to
some functions like file.write().
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index 4e7ea12..4d4ecc4 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -494,8 +494,21 @@
char *fieldfmt = dict->format ? dict->format : "B";
char *fieldname = PyString_AsString(name);
char *ptr;
- Py_ssize_t len = strlen(fieldname) + strlen(fieldfmt);
- char *buf = alloca(len + 2 + 1);
+ Py_ssize_t len;
+ char *buf;
+
+ if (fieldname == NULL)
+ {
+ PyErr_Format(PyExc_TypeError,
+ "structure field name must be string not %s",
+ name->ob_type->tp_name);
+
+ Py_DECREF(pair);
+ return -1;
+ }
+
+ len = strlen(fieldname) + strlen(fieldfmt);
+ buf = alloca(len + 2 + 1);
sprintf(buf, "%s:%s:", fieldfmt, fieldname);