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,
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;
}
}
}
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;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="_decimal"
ProjectGUID="{0E9791DB-593A-465F-98BC-681011311617}"
RootNamespace="_decimal"
@ -42,8 +42,8 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
AdditionalOptions="/D_CRT_SECURE_NO_WARNINGS /DCONFIG_32 /DPPRO /DMASM"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -104,8 +104,8 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
AdditionalOptions="/D_CRT_SECURE_NO_WARNINGS /DCONFIG_64 /DMASM"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -166,8 +166,8 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
AdditionalOptions="/D_CRT_SECURE_NO_WARNINGS /DCONFIG_32 /DPPRO /DMASM"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -230,8 +230,8 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
AdditionalOptions="/D_CRT_SECURE_NO_WARNINGS /DCONFIG_64 /DMASM"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -293,8 +293,8 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D_CRT_SECURE_NO_WARNINGS /DCONFIG_32 /DPPRO /DMASM"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
AdditionalOptions="/DCONFIG_32 /DPPRO /D_CRT_SECURE_NO_WARNINGS"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -357,8 +357,8 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D_CRT_SECURE_NO_WARNINGS /DCONFIG_64 /DMASM"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
AdditionalOptions="/DCONFIG_64 /D_CRT_SECURE_NO_WARNINGS"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -421,8 +421,8 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D_CRT_SECURE_NO_WARNINGS /DCONFIG_32 /DPPRO /DMASM"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
AdditionalOptions="/DCONFIG_32 /DPPRO /D_CRT_SECURE_NO_WARNINGS"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -485,8 +485,8 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D_CRT_SECURE_NO_WARNINGS /DCONFIG_64 /DMASM"
AdditionalIncludeDirectories="..\Modules\_decimal;..\Modules\_decimal\libmpdec"
AdditionalOptions="/DCONFIG_64 /D_CRT_SECURE_NO_WARNINGS"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -532,10 +532,6 @@
<Filter
Name="Header Files"
>
<File
RelativePath="..\Modules\_decimal\docstrings.h"
>
</File>
<File
RelativePath="..\Modules\_decimal\libmpdec\basearith.h"
>
@ -560,6 +556,10 @@
RelativePath="..\Modules\_decimal\libmpdec\difradix2.h"
>
</File>
<File
RelativePath="..\Modules\_decimal\docstrings.h"
>
</File>
<File
RelativePath="..\Modules\_decimal\libmpdec\fnt.h"
>

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