Commit f4228b0e authored by Georg Brandl's avatar Georg Brandl

Merge.

parents d3fca8e0 9ee601e1
...@@ -104,6 +104,13 @@ def arbitrary_address(family): ...@@ -104,6 +104,13 @@ def arbitrary_address(family):
else: else:
raise ValueError('unrecognized family') raise ValueError('unrecognized family')
def _validate_family(family):
'''
Checks if the family is valid for the current environment.
'''
if sys.platform != 'win32' and family == 'AF_PIPE':
raise ValueError('Family %s is not recognized.' % family)
def address_type(address): def address_type(address):
''' '''
...@@ -436,6 +443,7 @@ class Listener(object): ...@@ -436,6 +443,7 @@ class Listener(object):
or default_family or default_family
address = address or arbitrary_address(family) address = address or arbitrary_address(family)
_validate_family(family)
if family == 'AF_PIPE': if family == 'AF_PIPE':
self._listener = PipeListener(address, backlog) self._listener = PipeListener(address, backlog)
else: else:
...@@ -473,6 +481,7 @@ def Client(address, family=None, authkey=None): ...@@ -473,6 +481,7 @@ def Client(address, family=None, authkey=None):
Returns a connection to the address of a `Listener` Returns a connection to the address of a `Listener`
''' '''
family = family or address_type(address) family = family or address_type(address)
_validate_family(family)
if family == 'AF_PIPE': if family == 'AF_PIPE':
c = PipeClient(address) c = PipeClient(address)
else: else:
......
...@@ -2638,8 +2638,20 @@ class TestWait(unittest.TestCase): ...@@ -2638,8 +2638,20 @@ class TestWait(unittest.TestCase):
p.join() p.join()
#
# Issue 14151: Test invalid family on invalid environment
#
class TestInvalidFamily(unittest.TestCase):
@unittest.skipIf(WIN32, "skipped on Windows")
def test_invalid_family(self):
with self.assertRaises(ValueError):
multiprocessing.connection.Listener(r'\\.\test')
testcases_other = [OtherTest, TestInvalidHandle, TestInitializers, testcases_other = [OtherTest, TestInvalidHandle, TestInitializers,
TestStdinBadfiledescriptor, TestWait] TestStdinBadfiledescriptor, TestWait, TestInvalidFamily]
# #
# #
......
...@@ -1859,16 +1859,6 @@ class BasicElementTest(unittest.TestCase): ...@@ -1859,16 +1859,6 @@ class BasicElementTest(unittest.TestCase):
gc_collect() gc_collect()
self.assertIsNone(wref()) self.assertIsNone(wref())
# A longer cycle: d->e->e2->d
e = ET.Element('joe')
d = Dummy()
d.dummyref = e
wref = weakref.ref(d)
e2 = ET.SubElement(e, 'foo', attr=d)
del d, e, e2
gc_collect()
self.assertIsNone(wref())
class ElementTreeTest(unittest.TestCase): class ElementTreeTest(unittest.TestCase):
def test_istype(self): def test_istype(self):
......
...@@ -10,9 +10,16 @@ What's New in Python 3.3.0 Alpha 3? ...@@ -10,9 +10,16 @@ What's New in Python 3.3.0 Alpha 3?
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #13019: Fix potential reference leaks in bytearray.extend(). Patch
by Suman Saha.
Library Library
------- -------
- Issue #14151: Raise a ValueError, not a NameError, when trying to create
a multiprocessing Client or Listener with an AF_PIPE type address under
non-Windows platforms. Patch by Popa Claudiu.
What's New in Python 3.3.0 Alpha 2? What's New in Python 3.3.0 Alpha 2?
=================================== ===================================
......
...@@ -84,7 +84,10 @@ print("\n# ===================================================================== ...@@ -84,7 +84,10 @@ print("\n# =====================================================================
print("# Factorial") print("# Factorial")
print("# ======================================================================\n") print("# ======================================================================\n")
C.getcontext().prec = C.MAX_PREC c = C.getcontext()
c.prec = C.MAX_PREC
c.Emax = C.MAX_EMAX
c.Emin = C.MIN_EMIN
for n in [100000, 1000000]: for n in [100000, 1000000]:
......
...@@ -2289,8 +2289,10 @@ bytearray_extend(PyByteArrayObject *self, PyObject *arg) ...@@ -2289,8 +2289,10 @@ bytearray_extend(PyByteArrayObject *self, PyObject *arg)
} }
bytearray_obj = PyByteArray_FromStringAndSize(NULL, buf_size); bytearray_obj = PyByteArray_FromStringAndSize(NULL, buf_size);
if (bytearray_obj == NULL) if (bytearray_obj == NULL) {
Py_DECREF(it);
return NULL; return NULL;
}
buf = PyByteArray_AS_STRING(bytearray_obj); buf = PyByteArray_AS_STRING(bytearray_obj);
while ((item = PyIter_Next(it)) != NULL) { while ((item = PyIter_Next(it)) != NULL) {
...@@ -2323,8 +2325,10 @@ bytearray_extend(PyByteArrayObject *self, PyObject *arg) ...@@ -2323,8 +2325,10 @@ bytearray_extend(PyByteArrayObject *self, PyObject *arg)
return NULL; return NULL;
} }
if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1) if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1) {
Py_DECREF(bytearray_obj);
return NULL; return NULL;
}
Py_DECREF(bytearray_obj); Py_DECREF(bytearray_obj);
Py_RETURN_NONE; Py_RETURN_NONE;
......
...@@ -490,26 +490,22 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context) ...@@ -490,26 +490,22 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
for (i = 0; i < PyTuple_GET_SIZE(value); i++) { for (i = 0; i < PyTuple_GET_SIZE(value); i++) {
ob = PyTuple_GET_ITEM(value, i); ob = PyTuple_GET_ITEM(value, i);
if (!PyType_Check(ob)) { if (!PyType_Check(ob)) {
PyErr_Format( PyErr_Format(PyExc_TypeError,
PyExc_TypeError, "%s.__bases__ must be tuple of classes, not '%s'",
"%s.__bases__ must be tuple of classes, not '%s'", type->tp_name, Py_TYPE(ob)->tp_name);
type->tp_name, Py_TYPE(ob)->tp_name); return -1;
return -1;
} }
if (PyType_Check(ob)) { if (PyType_IsSubtype((PyTypeObject*)ob, type)) {
if (PyType_IsSubtype((PyTypeObject*)ob, type)) { PyErr_SetString(PyExc_TypeError,
PyErr_SetString(PyExc_TypeError, "a __bases__ item causes an inheritance cycle");
"a __bases__ item causes an inheritance cycle"); return -1;
return -1;
}
} }
} }
new_base = best_base(value); new_base = best_base(value);
if (!new_base) { if (!new_base)
return -1; return -1;
}
if (!compatible_for_assignment(type->tp_base, new_base, "__bases__")) if (!compatible_for_assignment(type->tp_base, new_base, "__bases__"))
return -1; return -1;
......
This diff is collapsed.
...@@ -97,7 +97,9 @@ extensions = [ ...@@ -97,7 +97,9 @@ extensions = [
'_sqlite3.pyd', '_sqlite3.pyd',
'_hashlib.pyd', '_hashlib.pyd',
'_multiprocessing.pyd', '_multiprocessing.pyd',
'_lzma.pyd' '_lzma.pyd',
'_decimal.pyd',
'_testbuffer.pyd'
] ]
# Well-known component UUIDs # Well-known component UUIDs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment