diff options
-rw-r--r-- | Doc/c-api/module.rst | 2 | ||||
-rw-r--r-- | Doc/includes/email-dir.py | 2 | ||||
-rw-r--r-- | Doc/includes/email-mime.py | 2 | ||||
-rw-r--r-- | Doc/includes/email-simple.py | 2 | ||||
-rw-r--r-- | Doc/library/mmap.rst | 4 | ||||
-rw-r--r-- | Doc/library/stdtypes.rst | 10 | ||||
-rw-r--r-- | Doc/library/sys.rst | 14 | ||||
-rw-r--r-- | Lib/test/test_descr.py | 16 | ||||
-rw-r--r-- | Lib/test/test_zlib.py | 2 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS | 8 | ||||
-rw-r--r-- | Misc/python.man | 4 | ||||
-rw-r--r-- | Modules/mmapmodule.c | 9 | ||||
-rw-r--r-- | Objects/descrobject.c | 9 |
14 files changed, 65 insertions, 20 deletions
diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst index 2c7faf0d2e..12816c9fd8 100644 --- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -192,7 +192,7 @@ These functions are usually used in the module initialization function. .. cfunction:: int PyModule_AddIntMacro(PyObject *module, macro) Add an int constant to *module*. The name and the value are taken from - *macro*. For example ``PyModule_AddConstant(module, AF_INET)`` adds the int + *macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int constant *AF_INET* with the value of *AF_INET* to *module*. Return ``-1`` on error, ``0`` on success. diff --git a/Doc/includes/email-dir.py b/Doc/includes/email-dir.py index e67de61dcf..035442bc3a 100644 --- a/Doc/includes/email-dir.py +++ b/Doc/includes/email-dir.py @@ -105,7 +105,7 @@ must be running an SMTP server. fp.write(composed) fp.close() else: - s = smtplib.SMTP() + s = smtplib.SMTP('localhost') s.sendmail(opts.sender, opts.recipients, composed) s.quit() diff --git a/Doc/includes/email-mime.py b/Doc/includes/email-mime.py index f64df83b4d..7b1c028fad 100644 --- a/Doc/includes/email-mime.py +++ b/Doc/includes/email-mime.py @@ -26,6 +26,6 @@ for file in pngfiles: msg.attach(img) # Send the email via our own SMTP server. -s = smtplib.SMTP() +s = smtplib.SMTP('localhost') s.sendmail(me, family, msg.as_string()) s.quit() diff --git a/Doc/includes/email-simple.py b/Doc/includes/email-simple.py index 689511e4bb..29bd0782d6 100644 --- a/Doc/includes/email-simple.py +++ b/Doc/includes/email-simple.py @@ -19,6 +19,6 @@ msg['To'] = you # Send the message via our own SMTP server, but don't include the # envelope header. -s = smtplib.SMTP() +s = smtplib.SMTP('localhost') s.sendmail(me, [you], msg.as_string()) s.quit() diff --git a/Doc/library/mmap.rst b/Doc/library/mmap.rst index 5001d4f55e..e061088a69 100644 --- a/Doc/library/mmap.rst +++ b/Doc/library/mmap.rst @@ -86,6 +86,10 @@ To map anonymous memory, -1 should be passed as the fileno along with the length defaults to 0. *offset* must be a multiple of the PAGESIZE or ALLOCATIONGRANULARITY. + To ensure validity of the created memory mapping the file specified + by the descriptor *fileno* is internally automatically synchronized + with physical backing store on Mac OS X and OpenVMS. + This example shows a simple way of using :class:`mmap`:: import mmap diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index a1a38791b4..7621eef4ae 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -353,8 +353,8 @@ Notes: for a complete list of code points with the ``Nd`` property. -All :class:`numbers.Real` types (:class:`int` and -:class:`float`) also include the following operations: +All :class:`numbers.Real` types (:class:`int` and :class:`float`) also include +the following operations: +--------------------+------------------------------------+--------+ | Operation | Result | Notes | @@ -438,6 +438,9 @@ Notes: Additional Methods on Integer Types ----------------------------------- +The int type implements the :class:`numbers.Integral` :term:`abstract base +class`. In addition, it provides one more method: + .. method:: int.bit_length() Return the number of bits necessary to represent an integer in binary, @@ -468,7 +471,8 @@ Additional Methods on Integer Types Additional Methods on Float --------------------------- -The float type has some additional methods. +The float type implements the :class:`numbers.Real` :term:`abstract base +class`. float also has the following additional methods. .. method:: float.as_integer_ratio() diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index c61fedb45a..bb9f920587 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -450,10 +450,10 @@ always available. struct sequence :data:`sys.version_info` may be used for a more human-friendly encoding of the same information. - The ``hexversion`` is a 32-bit number with the following layout + The ``hexversion`` is a 32-bit number with the following layout: +-------------------------+------------------------------------------------+ - | bits (big endian order) | meaning | + | Bits (big endian order) | Meaning | +=========================+================================================+ | :const:`1-8` | ``PY_MAJOR_VERSION`` (the ``2`` in | | | ``2.1.0a3``) | @@ -465,14 +465,14 @@ always available. | | ``2.1.0a3``) | +-------------------------+------------------------------------------------+ | :const:`25-28` | ``PY_RELEASE_LEVEL`` (``0xA`` for alpha, | - | | ``0xB`` for beta, ``0xC`` for gamma and | - | | ``0xF`` for final) | + | | ``0xB`` for beta, ``0xC`` for release | + | | candidate and ``0xF`` for final) | +-------------------------+------------------------------------------------+ | :const:`29-32` | ``PY_RELEASE_SERIAL`` (the ``3`` in | - | | ``2.1.0a3``) | + | | ``2.1.0a3``, zero for final releases) | +-------------------------+------------------------------------------------+ - thus ``2.1.0a3`` is hexversion ``0x020100a3`` + Thus ``2.1.0a3`` is hexversion ``0x020100a3``. .. data:: int_info @@ -480,7 +480,7 @@ always available. internal representation of integers. The attributes are read only. +-------------------------+----------------------------------------------+ - | attribute | explanation | + | Attribute | Explanation | +=========================+==============================================+ | :const:`bits_per_digit` | number of bits held in each digit. Python | | | integers are stored internally in base | diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index bd88f45337..aafe428bd0 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4235,6 +4235,22 @@ order (MRO) for bases """ with self.assertRaises(AttributeError): del X.__abstractmethods__ + def test_proxy_call(self): + class FakeStr: + __class__ = str + + fake_str = FakeStr() + # isinstance() reads __class__ + self.assertTrue(isinstance(fake_str, str)) + + # call a method descriptor + with self.assertRaises(TypeError): + str.split(fake_str) + + # call a slot wrapper descriptor + with self.assertRaises(TypeError): + str.__add__(fake_str, "abc") + class DictProxyTests(unittest.TestCase): def setUp(self): diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 48ac40a4f7..7593c064b0 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -74,7 +74,7 @@ class ChecksumBigBufferTestCase(unittest.TestCase): with open(support.TESTFN, "wb+") as f: f.seek(_4G) f.write(b"asdf") - with open(support.TESTFN, "rb") as f: + f.flush() self.mapping = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) def tearDown(self): @@ -777,6 +777,7 @@ Michael Stone Ken Stox Dan Stromberg Daniel Stutzbach +Andreas Stührk Pal Subbiah Nathan Sullivan Mark Summerfield @@ -10,6 +10,11 @@ What's New in Python 3.1.4? Core and Builtins ----------------- +- Issue #9756: When calling a method descriptor or a slot wrapper descriptor, + the check of the object type doesn't read the __class__ attribute anymore. + Fix a crash if a class override its __class__ attribute (e.g. a proxy of the + str type). Patch written by Andreas Stührk. + - Issue #6780: fix starts/endswith error message to mention that tuples are accepted too. @@ -61,6 +66,9 @@ Core and Builtins Library ------- +- Issue #11277: mmap.mmap() calls fcntl(fd, F_FULLFSYNC) on Mac OS X to get + around a mmap bug with sparse files. Patch written by Steffen Daode Nurpmeso. + - Issue #11763: don't use difflib in TestCase.assertMultiLineEqual if the strings are too long. diff --git a/Misc/python.man b/Misc/python.man index 87f1c93c70..411a43a3e7 100644 --- a/Misc/python.man +++ b/Misc/python.man @@ -31,7 +31,7 @@ python \- an interpreted, interactive, object-oriented programming language .B \-O ] [ -.B \-O0 +.B \-OO ] [ .B -Q @@ -142,7 +142,7 @@ compiled (bytecode) files from .I .pyc to \fI.pyo\fP. Given twice, causes docstrings to be discarded. .TP -.B \-O0 +.B \-OO Discard docstrings in addition to the \fB-O\fP optimizations. .TP .BI "\-Q " argument diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index f484a7a75b..88da4a0ac6 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -23,6 +23,9 @@ #ifndef MS_WINDOWS #define UNIX +# ifdef __APPLE__ +# include <fcntl.h> +# endif #endif #ifdef MS_WINDOWS @@ -1091,6 +1094,12 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) "mmap invalid access parameter."); } +#ifdef __APPLE__ + /* Issue #11277: fsync(2) is not enough on OS X - a special, OS X specific + fcntl(2) is necessary to force DISKSYNC and get around mmap(2) bug */ + if (fd != -1) + (void)fcntl(fd, F_FULLFSYNC); +#endif #ifdef HAVE_FSTAT # ifdef __VMS /* on OpenVMS we must ensure that all bytes are written to the file */ diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 5f118ce09e..9eda4bdd7d 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -226,7 +226,8 @@ methoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwds) return NULL; } self = PyTuple_GET_ITEM(args, 0); - if (!PyObject_IsInstance(self, (PyObject *)(descr->d_type))) { + if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self), + (PyObject *)(descr->d_type))) { PyErr_Format(PyExc_TypeError, "descriptor '%V' " "requires a '%.100s' object " @@ -284,7 +285,8 @@ wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds) return NULL; } self = PyTuple_GET_ITEM(args, 0); - if (!PyObject_IsInstance(self, (PyObject *)(descr->d_type))) { + if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self), + (PyObject *)(descr->d_type))) { PyErr_Format(PyExc_TypeError, "descriptor '%V' " "requires a '%.100s' object " @@ -1065,7 +1067,8 @@ PyWrapper_New(PyObject *d, PyObject *self) assert(PyObject_TypeCheck(d, &PyWrapperDescr_Type)); descr = (PyWrapperDescrObject *)d; - assert(PyObject_IsInstance(self, (PyObject *)(descr->d_type))); + assert(_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self), + (PyObject *)(descr->d_type))); wp = PyObject_GC_New(wrapperobject, &wrappertype); if (wp != NULL) { |