This commit is contained in:
Georg Brandl 2012-04-02 07:52:29 +02:00
commit f4228b0e6a
9 changed files with 794 additions and 771 deletions

View File

@ -104,6 +104,13 @@ def arbitrary_address(family):
else:
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):
'''
@ -436,6 +443,7 @@ class Listener(object):
or default_family
address = address or arbitrary_address(family)
_validate_family(family)
if family == 'AF_PIPE':
self._listener = PipeListener(address, backlog)
else:
@ -473,6 +481,7 @@ def Client(address, family=None, authkey=None):
Returns a connection to the address of a `Listener`
'''
family = family or address_type(address)
_validate_family(family)
if family == 'AF_PIPE':
c = PipeClient(address)
else:

View File

@ -2638,8 +2638,20 @@ class TestWait(unittest.TestCase):
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,
TestStdinBadfiledescriptor, TestWait]
TestStdinBadfiledescriptor, TestWait, TestInvalidFamily]
#
#

View File

@ -1859,16 +1859,6 @@ class BasicElementTest(unittest.TestCase):
gc_collect()
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):
def test_istype(self):

View File

@ -10,9 +10,16 @@ What's New in Python 3.3.0 Alpha 3?
Core and Builtins
-----------------
- Issue #13019: Fix potential reference leaks in bytearray.extend(). Patch
by Suman Saha.
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?
===================================

View File

@ -84,7 +84,10 @@ print("\n# =====================================================================
print("# Factorial")
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]:

View File

@ -2289,8 +2289,10 @@ bytearray_extend(PyByteArrayObject *self, PyObject *arg)
}
bytearray_obj = PyByteArray_FromStringAndSize(NULL, buf_size);
if (bytearray_obj == NULL)
if (bytearray_obj == NULL) {
Py_DECREF(it);
return NULL;
}
buf = PyByteArray_AS_STRING(bytearray_obj);
while ((item = PyIter_Next(it)) != NULL) {
@ -2323,8 +2325,10 @@ bytearray_extend(PyByteArrayObject *self, PyObject *arg)
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;
}
Py_DECREF(bytearray_obj);
Py_RETURN_NONE;

View File

@ -490,26 +490,22 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
for (i = 0; i < PyTuple_GET_SIZE(value); i++) {
ob = PyTuple_GET_ITEM(value, i);
if (!PyType_Check(ob)) {
PyErr_Format(
PyExc_TypeError,
"%s.__bases__ must be tuple of classes, not '%s'",
type->tp_name, Py_TYPE(ob)->tp_name);
return -1;
PyErr_Format(PyExc_TypeError,
"%s.__bases__ must be tuple of classes, not '%s'",
type->tp_name, Py_TYPE(ob)->tp_name);
return -1;
}
if (PyType_Check(ob)) {
if (PyType_IsSubtype((PyTypeObject*)ob, type)) {
PyErr_SetString(PyExc_TypeError,
"a __bases__ item causes an inheritance cycle");
return -1;
}
if (PyType_IsSubtype((PyTypeObject*)ob, type)) {
PyErr_SetString(PyExc_TypeError,
"a __bases__ item causes an inheritance cycle");
return -1;
}
}
new_base = best_base(value);
if (!new_base) {
if (!new_base)
return -1;
}
if (!compatible_for_assignment(type->tp_base, new_base, "__bases__"))
return -1;

File diff suppressed because it is too large Load Diff

View File

@ -97,7 +97,9 @@ extensions = [
'_sqlite3.pyd',
'_hashlib.pyd',
'_multiprocessing.pyd',
'_lzma.pyd'
'_lzma.pyd',
'_decimal.pyd',
'_testbuffer.pyd'
]
# Well-known component UUIDs