Commit Graph

6400 Commits

Author SHA1 Message Date
Zackery Spytz d61f586df7 [2.7] bpo-35068: Fix possible crashes in pyexpat.c. (GH-10099) 2018-10-29 09:23:59 +02:00
Serhiy Storchaka aaea2802da
[2.7] bpo-34794: Fix a leak in Tkinter. (GH-10025) (GH-10181)
Based on the investigation by Xiang Zhang.
(cherry picked from commit df13df41a2)
2018-10-28 19:36:02 +02:00
Zackery Spytz e131c7cf78 [2.7] Fix error handling bugs in _elementtree.c. (GH-10060) (GH-10080)
Don't leak a reference if PyDict_Update() fails, check the
PyList_New() call in treebuilder_new(), and properly handle failures
in xmlparser().

(cherry picked from commit 9f3ed3e213)
2018-10-26 08:37:07 +03:00
Miss Islington (bot) 5744a33629
Fix several reference counting bugs in pyexpat.c. (GH-9955)
(cherry picked from commit 68def052dc)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-10-19 00:26:37 -07:00
Vladimir Matveev b63a16febb [2.7] bpo-34603, ctypes/libffi_msvc: Fix returning structs from functions (GH-9258) (GH-9425)
Co-authored-by: Vladimir Matveev <v2matveev@outlook.com>
2018-09-19 13:48:21 -07:00
Christian Heimes 18b20bad75 [2.7] bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146) (GH-9394)
The C accelerated _elementtree module now initializes hash randomization
salt from _Py_HashSecret instead of libexpat's default CPRNG.

Signed-off-by: Christian Heimes <christian@python.org>

https://bugs.python.org/issue34623.
(cherry picked from commit cb5778f00c)

Co-authored-by: Christian Heimes <christian@python.org>



https://bugs.python.org/issue34623
2018-09-18 06:13:09 -07:00
Christian Heimes 5f883fcb9b [2.7] bpo-34710: fix SSL module build (GH-9347) (GH-9353)
Include ``openssl/dh.h`` header file to fix implicit function declaration of ``DH_free()``.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>.
(cherry picked from commit b3a271fc0c)

Co-authored-by: Alexandru Ardelean <ardeleanalex@gmail.com>



https://bugs.python.org/issue34710
2018-09-17 06:42:30 -07:00
Miss Islington (bot) 669429fb58 bpo-34649: Add missing NULL checks to _encoded_const() (GH-9225)
Reported by Svace static analyzer.
(cherry picked from commit 6f82bffd2d)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-09-13 01:00:56 +03:00
Zackery Spytz b36567bef8 [2.7] bpo-28994: Remove mistakenly backported atexitmodule.c (GH-9214)
It was backported in 0cc43df05e.
2018-09-12 14:28:18 +03:00
Benjamin Peterson b663205ca9
[2.7] Delete old expat comment. (GH-9205)
(cherry picked from commit b9bf9d025e)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-09-11 18:28:35 -07:00
Benjamin Peterson 253279c616
[2.7] closes bpo-31608: Fix a crash in methods of a subclass of _collections.deque with a bad __new__(). (GH-9179) 2018-09-11 13:41:57 -07:00
Miss Islington (bot) 7a501def4f
bpo-34625: Update vendorized expat version to 2.2.6. (GH-9150)
(cherry picked from commit 5033aa77aa)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-09-10 21:26:42 -07:00
Benjamin Peterson ed62e64510
[2.7] Fix misleading mentions of tp_size in comments (GH-9138)
Many type object initializations labeled a field "tp_size" in the
comment, but the name of that field is tp_basicsize..
(cherry picked from commit 0e0bc4e221)

Co-authored-by: Peter Eisentraut <peter@eisentraut.org>
2018-09-10 10:50:15 -07:00
Zackery Spytz 032e85f3fb bpo-34491: Add missing Py_DECREF() in _bsddb's DB_join() (GH-8909) 2018-08-25 12:22:21 +08:00
Sergey Fedoseev ae1f012729 bpo-34395: Fix memory leaks caused by incautious usage of PyMem_Realloc(). (GH-8785) 2018-08-17 08:36:15 +03:00
Miss Islington (bot) 396afbf771
Fix docstring of Profiler class (GH-8651)
(cherry picked from commit 2ebd3813af)

Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
2018-08-03 02:43:18 -07:00
Victor Stinner dd4d8b4d80
Fix compilation warnings on Windows (GH-8627)
* Fix compilation warning in _ctypes module on Window

(cherry picked from commit 20f11fe43c)

* Fix compilation warnings on Windows 64-bit

(cherry picked from commit 725e421222)

* Fix compiler warning in unicodeobject.c

Explicitly case to Py_UNICODE to fix the warning:

Objects\unicodeobject.c(4225): warning C4244: '=' :
conversion from 'long' to 'Py_UNICODE', possible loss of data

The downcast cannot overflow since we check that value <= 0x10ffff.
2018-08-02 18:02:59 +02:00
Victor Stinner 6a6b248347
bpo-29565: Fix compilation for C89 (GH-8626)
Use a local scope for the 'i' variable.
2018-08-02 17:40:11 +02:00
Victor Stinner 3243f8c1fb
bpo-29565: Corrected ctypes passing of large structs by value on Windows AMD64 (GH-168) (GH-8625)
Fixed bpo-29565: Corrected ctypes passing of large structs by value.

Added code and test to check that when a structure passed by value
is large enough to need to be passed by reference, a copy of the
original structure is passed. The callee updates the passed-in value,
and the test verifies that the caller's copy is unchanged. A similar
change was also added to the test added for bpo-20160 (that test was
passing, but the changes should guard against regressions).

(cherry picked from commit a86339b83f)
2018-08-02 16:47:26 +02:00
Serhiy Storchaka 48c8bf21f9
[2.7] bpo-34234: Use _PyAnyInt_Check() and _PyAnyInt_CheckExact(). (GH-8479) 2018-07-31 09:09:36 +03:00
Xtreak 2bea771609 bpo-34229: Check start and stop of slice object to be long when they are not int in PySlice_GetIndices (GH-8480) 2018-07-26 19:20:34 +03:00
Zackery Spytz 041a4ee945 bpo-25943: Check for integer overflow in bsddb's DB_join(). (GH-8392) 2018-07-22 19:53:56 +03:00
Zackery Spytz 3252205077 bpo-25943: Fix potential heap corruption in bsddb's _db_associateCallback() (GH-8337)
There was a missing check for integer overflow, several function calls
were not checked for failure, and allocated memory was not freed if an
error occurred.
2018-07-21 11:27:44 +03:00
Serhiy Storchaka fc153d1279
[2.7] bpo-34068: iobase_close could call PyObject_SetAttrString with an exception set (GH-8282). (GH-8312) (GH-8314)
(cherry picked from commit 28f07364f0)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>.
(cherry picked from commit cc13016658)
2018-07-17 18:15:46 +03:00
Serhiy Storchaka ef19fd200d
[2.7] bpo-23927: Make getargs.c skipitem() skipping 'w*'. (GH-8192). (GH-8255)
(cherry picked from commit 504373c59b)

Also backport tests for skipitem() and handling errors.
2018-07-11 19:49:17 +03:00
Benjamin Peterson dc39a59bc7
[2.7] prefix internal sqlite symbols with _pysqlite_ (GH-8215). (GH-8217)
(cherry picked from commit 7762e4d387)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-07-09 22:36:49 -07:00
Benjamin Peterson 695ecd9dc6
[2.7] delete some unused pysqlite forward declarations (GH-8211). (GH-8214)
(cherry picked from commit d6d4432724)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-07-09 21:12:57 -07:00
Miss Islington (bot) bfee59018f
Don't export pending_threadfunc from _testcapi. (GH-8075)
(cherry picked from commit b4588c2fff)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-07-03 22:48:45 -07:00
Zackery Spytz 0464de0f9a [2.7] bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918). (GH-8013)
(cherry picked from commit 23db935bcf)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-06-29 23:07:13 +03:00
Benjamin Peterson 468f97b464
[2.7] closes bpo-33956: update vendored expat to 2.2.5 (GH-7925)
(cherry picked from commit 4e21100fa7)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-06-26 20:56:58 -07:00
Victor Stinner 70c3d5846a
Fix compiler warnings on Windows (GH-7729)
Fix comparison between signed and unsigned integers. Example of fixed
warning:

Modules\_sre.c(838): warning C4018: '<' : signed/unsigned mismatch

(cherry picked from commit 1fa174a418)
2018-06-16 00:33:51 +02:00
Xiang Zhang 1889c4cbd6
bpo-29456: Fix bugs in unicodedata.normalize: u1176, u11a7 and u11c3 (GH-1958) (GH-7704)
Hangul composition check boundaries are wrong for the second character
([0x1161, 0x1176) instead of [0x1161, 0x1176]) and third character ((0x11A7, 0x11C3)
instead of [0x11A7, 0x11C3])..
(cherry picked from commit d134809cd3)

Co-authored-by: Wonsup Yoon <pusnow@me.com>
2018-06-15 21:26:55 +08:00
Victor Stinner e5b79c5463
bpo-19418: audioop.c: Fix warnings on -0x80000000 (GH-7453)
bpo-19418, bpo-33781: Fix the following warnings on Windows:

Modules\audioop.c(28): warning C4146: unary minus operator applied
    to unsigned type, result still unsigned
Modules\audioop.c(396): warning C4146: unary minus operator applied
    to unsigned type, result still unsigned
2018-06-06 17:51:07 +02:00
Victor Stinner b17d409bc0
bpo-33781: audioop: enhance rounding double as int (GH-7447) (GH-7452)
Move the floor() call into fbound() to call floor() on a double
rather than an int. The change should enhance the rounding.

Document also (int)double rounding mode.

(cherry picked from commit 45e4efba7f)
2018-06-06 17:12:39 +02:00
Serhiy Storchaka 3014d6eb7f
[2.7] bpo-33767: Fix improper use of SystemError by mmap.mmap objects (GH-7381) (GH-7432)
Raise TypeError instead of SystemError for unsupported operations.
(cherry picked from commit e9e3976057)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-06-05 19:51:37 +03:00
Antoine Pitrou ded666ff0c
[2.7] bpo-30654: Do not reset SIGINT handler to SIG_DFL in finisignal (GH-7146) (GH-7347)
(cherry picked from commit e905c84494)
2018-06-03 20:46:43 +02:00
Serhiy Storchaka db1074244d
[2.7] bpo-33677: Fix the signature of tp_clear handler for deque. (GH-7196). (GH-7277)
(cherry picked from commit a5c42284e6)
2018-05-31 10:32:43 +03:00
Serhiy Storchaka 9044cd6759
[2.7] bpo-33622: Fix issues with handling errors in the GC. (GH-7078) (#7096)
* Fixed a leak when the GC fails to add an object with __del__ into
  the gc.garbage list.
* PyGC_Collect() can now be called when an exception is set and
  preserves it.
(cherry picked from commit 301e3cc8a5)
2018-05-24 23:27:08 +03:00
Miss Islington (bot) 3ccc31386d
bpo-33583: Add note in PyObject_GC_Resize() doc (GH-7021)
(cherry picked from commit 1179f4b40f)

Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
2018-05-21 07:10:27 -07:00
Serhiy Storchaka d988c0b6bd
[2.7] bpo-33308: Fix a crash in the parser module when convert an ST object. (GH-6519) (GH-6532)
Converting with line_info=False and col_info=True crashed before.
(cherry picked from commit e5362eaa75)
2018-04-19 09:16:43 +03:00
Serhiy Storchaka 924035a5e5
[2.7] Fix error message in sqlite connection thread check. (GH-6028). (GH-6325)
(cherry picked from commit 030345c0bf)

Co-authored-by: Takuya Akiba <469803+iwiwi@users.noreply.github.com>
2018-04-01 01:04:22 +03:00
scoder c498cd8bf8 bpo-31544: Fix a reference leak to 'self' after the previous target error handling fixes. (GH-6318)
This change generally splits the xmlparser creation code into an unsafe part with "rollback" error handling and a safe "object initialisation done" part with normal decref cleanup.
2018-03-31 15:23:30 +03:00
Christian Heimes edd541897b
[2.7] bpo-33127: Compatibility patch for LibreSSL 2.7.0 (GH-6210) (GH-6215)
LibreSSL 2.7 introduced OpenSSL 1.1.0 API. The ssl module now detects
LibreSSL 2.7 and only provides API shims for OpenSSL < 1.1.0 and
LibreSSL < 2.7.

Documentation updates and fixes for failing tests will be provided in
another patch set.

Signed-off-by: Christian Heimes <christian@python.org>.
(cherry picked from commit 4ca0739c9d)

Co-authored-by: Christian Heimes <christian@python.org>
2018-03-24 19:34:15 +01:00
scoder 0694b6a651 bpo-31544: Avoid calling "PyObject_GetAttrString()" (and potentially executing user code) with a live exception set. (GH-3992) 2018-03-24 07:56:41 +02:00
Miss Islington (bot) 7ee093614b
Fix typos in mmap() error messages (GH-6173)
(cherry picked from commit 9308dea3e1)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-03-20 23:55:44 -07:00
Alexey Izbyshev aa40f92240 [2.7] bpo-32903: Fix a memory leak in os.chdir() on Windows (GH-5801). (#5947)
(cherry picked from commit 3e197c7a67)

Co-authored-by: Alexey Izbyshev <izbyshev@users.noreply.github.com>
2018-03-01 18:27:34 +08:00
Christian Heimes df1732a473
[2.7] bpo-30622: Fix NPN for OpenSSL 1.1.1-pre1 (GH-5876) (#5882)
Signed-off-by: Christian Heimes <christian@python.org>.
(cherry picked from commit 29eab55309)

Co-authored-by: Christian Heimes <christian@python.org>
2018-02-25 14:28:55 +01:00
Christian Heimes 439956a149
Fix ssl module, Python 2.7 doesn't have Py_MAX (#5878)
Signed-off-by: Christian Heimes <christian@python.org>
2018-02-25 13:08:05 +01:00
Christian Heimes 3d87f4cf9c
[2.7] bpo-30622: Improve NPN support detection (GH-5859) (#5863)
The ssl module now detects missing NPN support in LibreSSL.

Co-Authored-By: Bernard Spil <brnrd@FreeBSD.org>
Signed-off-by: Christian Heimes <christian@python.org>.
(cherry picked from commit 6cdb7954b0)

Co-authored-by: Christian Heimes <christian@python.org>
2018-02-25 10:21:03 +01:00
Miss Islington (bot) a5c9112300 [2.7] bpo-32185: Don't send IP in SNI TLS extension (GH-5865) (#5871)
The SSL module no longer sends IP addresses in SNI TLS extension on
platforms with OpenSSL 1.0.2+ or inet_pton.

Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit e9370a4738)

Co-authored-by: Christian Heimes <christian@python.org>
2018-02-25 10:16:37 +01:00
Christian Heimes 6e8f395001
bpo-25404: SSLContext.load_dh_params() non-ASCII path (GH-3459)
SSLContext.load_dh_params() now supports non-ASCII path.

Signed-off-by: Christian Heimes <christian@python.org>
2018-02-25 09:48:02 +01:00
Miss Islington (bot) 836b642148
Update comment in posixmodule.c (GH-5681)
A closing parentheses was missing.

Signed-off-by: Ngie Cooper <yaneurabeya@gmail.com>
(cherry picked from commit 7745ec4e35)

Co-authored-by: ngie-eign <1574099+ngie-eign@users.noreply.github.com>
2018-02-14 12:43:17 -08:00
Anthony Sottile 27f32e938f bpo-32539: Fix OSError for os.listdir() for extended-length paths on Windows (#5169)
See https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx?f=255&MSPPError=-2147217396#maxpath

Paths that begin with `\\?\` are "extended-length paths".
2018-01-15 23:39:04 +02:00
Miss Islington (bot) e8ab7eb5c7 correct the typos (GH-4950) (#4952)
(cherry picked from commit 83cb778b4a)
2017-12-21 07:42:42 +02:00
Nir Soffer 830daae1c8 [2.7] bpo-32186: Release the GIL during fstat and lseek calls (#4651)
In fileio, there were 3 fstat() calls and one lseek() call that did not
release the GIL during the call. This can cause all threads to hang for
unlimited time when using io.FileIO with inaccessible NFS server.

Same issue seen in fileio exists also in fileobject, fixed in the same
way.
2017-12-07 21:25:39 +01:00
Serhiy Storchaka 1bce4efdb4
[2.7] bpo-31927: Fix reading arbitrary data when parse a AF_BLUETOOTH address (GH-4235) (GH-4352) (#4355)
on NetBSD and DragonFly BSD.
(cherry picked from commit d3187158c0).
(cherry picked from commit 596286f8f3)
2017-11-09 23:05:59 +02:00
Oren Milman cd66d6d632 bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (GH-4333) 2017-11-08 01:57:02 -08:00
Serhiy Storchaka 69ea4b4deb
Fix bpo-27666 backporting error in _cursesmodule.c (#4305) 2017-11-07 09:55:33 +02:00
Miss Islington (bot) 4b544aadd5 bpo-31770: Prevent a crash and refleaks when calling sqlite3.Cursor.__init__() more than once (GH-3968) (#4302)
(cherry picked from commit e56ab746a9)
2017-11-06 16:44:19 -08:00
Antoine Pitrou c713837e91
[2.7] bpo-30057: Fix potential missed signal in signal.signal(). (GH-4258) (#4263)
Bug report and patch by Jeroen Demeyer..
(cherry picked from commit f6f90ff079)
2017-11-03 20:36:39 +01:00
Miss Islington (bot) b694770a2b bpo-27666: Fixed stack corruption in curses.box() and curses.ungetmouse(). (GH-4220) (#4222)
(cherry picked from commit 4f469c0966)
2017-11-01 21:24:00 +02:00
Serhiy Storchaka ce51890894
bpo-31893: Fix a backporting error in 8cbf4e1064. (#4219) 2017-11-01 17:43:07 +02:00
Miss Islington (bot) 87c66e46ce bpo-31919: Fix building the curses module on OpenIndiana. (GH-4211) (#4216)
(cherry picked from commit 894ebd065e)
2017-11-01 15:11:18 +02:00
Miss Islington (bot) 6ba0b583d6 bpo-25720: Fix the method for checking pad state of curses WINDOW (GH-4164) (#4213)
Modify the code to use ncurses is_pad() instead of checking WINDOW
_flags field.  If your platform does not provide the is_pad(), the
existing way that checks the field will be enabled.

Note: This change does not drop support for platforms where do not
have both WINDOW _flags field and is_pad().
(cherry picked from commit 8bc7d63560)
2017-11-01 14:36:48 +02:00
Miss Islington (bot) e7531e54bf bpo-31893: Fix errors in b9052a0f91. (GH-4196) (#4202)
* Fix a compilation error on FreeBSD.
* Fix the data attribute size on Mac OS X.
(cherry picked from commit 2298fad5ff)
2017-10-31 20:16:11 +02:00
Serhiy Storchaka 8cbf4e1064
[2.7] bpo-31893: Fixed select.kqueue(). (GH-4166) (#4193)
* Fixed the layout of the kqueue_event structure on OpenBSD and NetBSD.
* Fixed the comparison of the kqueue_event objects..
(cherry picked from commit b9052a0f91)
2017-10-31 16:13:52 +02:00
Serhiy Storchaka e0fc1af67a
[2.7] bpo-31891: Fix building the curses module on NetBSD. (GH-4165). (#4194)
(cherry picked from commit baac01e629)
2017-10-31 16:12:35 +02:00
Serhiy Storchaka 5ef883b096 [2.7] bpo-31752: Fix possible crash in timedelta constructor called with custom integers. (GH-3947) (#4088)
Bad remainder in divmod() in intermediate calculations caused an assertion failure..
(cherry picked from commit 4ffd4653a7)
2017-10-23 19:57:04 +03:00
Riccardo Coccioli 27b951c633 [2.7] bpo-31334: Fix timeout in select.poll.poll() (GH-3277) (#4034)
Always pass -1, or INFTIM where defined, to the poll() system call when
a negative timeout is passed to the poll.poll([timeout]) method in the
select module. Various OSes throw an error with arbitrary negative
values..
(cherry picked from commit 6cfa927ceb)
2017-10-18 15:04:04 +03:00
Serhiy Storchaka 9aa60245a0 [2.7] bpo-30058: Fixed buffer overflow in select.kqueue.control(). (GH-1095). (#3976)
(cherry picked from commit de07210077)
2017-10-13 00:13:11 +03:00
Oren Milman fb3bb8d5d5 [2.7] bpo-31490: Fix an assertion failure in ctypes in case an _anonymous_ attr is defined only outside _fields_. (GH-3615) (#3952) 2017-10-12 17:39:01 +03:00
Oren Milman f15058a697 [2.7] bpo-31728: Prevent crashes in _elementtree due to unsafe cleanup of Element.text and Element.tail (GH-3924) (#3950) 2017-10-11 16:29:12 +03:00
Victor Stinner cc4b6f1c62 bpo-31719: Fix test_regrtest.test_crashed() on s390x (#3912)
Add a new _testcapi._read_null() function to crash Python in a
reliable way on s390x.

On s390x, ctypes.string_at(0) returns an empty string rather than
crashing.
2017-10-09 00:52:06 -07:00
Serhiy Storchaka 328b5d0e64 [2.7] bpo-31675: Fix memory leaks in Tkinter's methods splitlist() and split() (GH-3866) (#3876)
when pass a string larger than 2 GiB.

Decrease memory requirements for Tcl's bigmem tests..
(cherry picked from commit 27c623c845)
2017-10-04 21:37:53 +03:00
Oren Milman 13da1a60f1 [2.7] bpo-31478: Prevent unwanted behavior in _random.Random.seed() in case the arg has a bad __abs__() method (GH-3596) (#3845) 2017-10-03 00:31:42 +03:00
Victor Stinner 8b83687bdf bpo-28129: fix ctypes crashes (#386) (#3800)
* init commit, with initial tests for from_param and fields __set__ and __get__, and some additions to from_buffer and from_buffer_copy

* added the rest of tests and patches. probably only a first draft.

* removed trailing spaces

* replace ctype with ctypes in error messages

* change back from ctypes instance to ctype instance

(cherry picked from commit 1bea762d9e)
2017-09-28 07:31:40 -07:00
Miss Islington (bot) 9bfa55bfea [2.7] bpo-31490: Fix an assertion failure in ctypes in case an _anonymous_ attr is defined only outside _fields_. (GH-3615) (#3780)
(cherry picked from commit 30b61b51e0)
2017-09-27 09:52:44 +03:00
Serhiy Storchaka 81691b0548 [2.7] bpo-31311: Fix a SystemError and a crash in ctypes._CData.__setstate__(), in case of a bad __dict__. (GH-3254). (#3781)
(cherry picked from commit 57c2561c8c)
2017-09-27 09:24:39 +03:00
Serhiy Storchaka 4954b8dc53 [2.7] bpo-25359: Add missed "goto error" after setting an exception. (GH-3712) (#3779)
(cherry picked from commit d6238a76c6)
2017-09-27 08:44:03 +03:00
Serhiy Storchaka d0b9dc3367 [2.7] bpo-30347: Stop crashes when concurrently iterate over itertools.groupby() iterators. (GH-1557). (#3772)
(cherry picked from commit c740e4fe8a)
2017-09-26 23:15:36 +03:00
Benjamin Peterson a72d15c97f consistently use Py_TYPE, Py_REFCNT, and correct initializer macros (#3563)
This no-op change makes 2.7 more consistent with 3.x to ease comparison and backports.
2017-09-13 21:20:29 -07:00
Christian Heimes b9a860f3bf [2.7] bpo-29136: Add TLS 1.3 cipher suites and OP_NO_TLSv1_3 (GH-1363) (#3446)
* bpo-29136: Add TLS 1.3 support

TLS 1.3 introduces a new, distinct set of cipher suites. The TLS 1.3
cipher suites don't overlap with cipher suites from TLS 1.2 and earlier.
Since Python sets its own set of permitted ciphers, TLS 1.3 handshake
will fail as soon as OpenSSL 1.1.1 is released. Let's enable the common
AES-GCM and ChaCha20 suites.

Additionally the flag OP_NO_TLSv1_3 is added. It defaults to 0 (no op) with
OpenSSL prior to 1.1.1. This allows applications to opt-out from TLS 1.3
now.

Signed-off-by: Christian Heimes <christian@python.org>.
(cherry picked from commit cb5b68abde)
2017-09-07 22:31:17 -07:00
Christian Heimes 611a3eab19 [2.7] bpo-28958: Improve SSLContext error reporting. (GH-3414) (#3433)
Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 17c9ac9)
2017-09-07 16:45:07 -07:00
Benjamin Peterson eba0bad310 Merge branch 'release-2.7.14' into 2.7 2017-09-05 18:06:20 -07:00
Victor Stinner c00d5087cd bpo-31170: Update libexpat from 2.2.3 to 2.2.4 (#3315)
Fix copying of partial characters for UTF-8 input (libexpat bug 115):
https://github.com/libexpat/libexpat/issues/115

(cherry picked from commit 759e30ec47)

The standard header stdbool.h is not available
with old Visual Studio compilers

Cherry-picked from libexpat b4b89c2ab0cc5325a41360c25ef9d2ccbe617e5c.

expat: Add artificial scopes in xmltok.c utf8_toUtf8() to fix c89 compilation.

Cherry-picked from libexpat commit e0b290eb3d8f4c4b45137a7d7f4f8db812145bd2
2017-09-05 18:04:39 -07:00
Victor Stinner eeadf5fc23 bpo-31339: Rewrite time.asctime() and time.ctime() (#3293)
* bpo-31339: Rewrite time.asctime() and time.ctime()

Backport and adapt the _asctime() function from the master branch to
not depend on the implementation of asctime() and ctime() from the
external C library. This change fixes a bug when Python is run using
the musl C library.

* bound checks for time.asctime()

* bound checks for time.strftime()
2017-09-06 01:35:39 +02:00
Christian Heimes c9d668c0d8 [2.7] bpo-30502: Fix handling of long oids in ssl. (GH-2909). (#3322)
(cherry picked from commit e503ca5288)
2017-09-05 19:13:07 +02:00
Christian Heimes 7daa45db1d [2.7] bpo-30102: Call OPENSSL_add_all_algorithms_noconf (GH-3112) (#3343)
The ssl and hashlib modules now call OPENSSL_add_all_algorithms_noconf() on
OpenSSL < 1.1.0. The function detects CPU features and enables optimizations
on some CPU architectures such as POWER8. Patch is based on research from
Gustavo Serra Scalet.

Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit c941e62)
2017-09-05 17:12:12 +02:00
Christian Heimes ffa7011cb9 [2.7] bpo-31343: Include sys/sysmacros.h (GH-3318) (#3345)
Include sys/sysmacros.h for major(), minor(), and makedev(). GNU C libray
plans to remove the functions from sys/types.h.

Signed-off-by: Christian Heimes <christian@python.org>.
(cherry picked from commit 75b961869a)
2017-09-05 17:08:45 +02:00
Christian Heimes 72ed233167 [2.7] bpo-30622: Change NPN detection: (GH-2079) (#3316)
* Change NPN detection:

Version breakdown, support disabled (pre-patch/post-patch):
- pre-1.0.1: OPENSSL_NPN_NEGOTIATED will not be defined -> False/False
- 1.0.1 and 1.0.2: OPENSSL_NPN_NEGOTIATED will not be defined ->
False/False
- 1.1.0+: OPENSSL_NPN_NEGOTIATED will be defined and
OPENSSL_NO_NEXTPROTONEG will be defined -> True/False

Version breakdown support enabled (pre-patch/post-patch):
- pre-1.0.1: OPENSSL_NPN_NEGOTIATED will not be defined -> False/False
- 1.0.1 and 1.0.2: OPENSSL_NPN_NEGOTIATED will be defined and
OPENSSL_NO_NEXTPROTONEG will not be defined -> True/True
- 1.1.0+: OPENSSL_NPN_NEGOTIATED will be defined and
OPENSSL_NO_NEXTPROTONEG will not be defined -> True/True

* Refine NPN guard:

- If NPN is disabled, but ALPN is available we need our callback
- Make clinic's ssl behave the same way

This created a working ssl module for me, with NPN disabled and ALPN
enabled for OpenSSL 1.1.0f.

Concerns to address:
The initial commit for NPN support into OpenSSL [1], had the
OPENSSL_NPN_* variables defined inside the OPENSSL_NO_NEXTPROTONEG
guard. The question is if that ever made it into a release.
This would need an ugly hack, something like:

	GH-if defined(OPENSSL_NO_NEXTPROTONEG) && \
		!defined(OPENSSL_NPN_NEGOTIATED)
	GH-	define OPENSSL_NPN_UNSUPPORTED 0
	GH-	define OPENSSL_NPN_NEGOTIATED 1
	GH-	define OPENSSL_NPN_NO_OVERLAP 2
	GH-endif

[1] https://github.com/openssl/openssl/commit/68b33cc5c7.
(cherry picked from commit b2d096bd2a)
2017-09-05 01:11:40 +02:00
INADA Naoki 4cde4bdcc8 bpo-31095: Fix potential crash during GC (GH-3197)
(cherry picked from commit a6296d34a4)
2017-09-04 12:31:41 +09:00
Pauli Virtanen 990b2d043c [2.7] bpo-10746: Fix ctypes PEP 3118 type codes for c_long, c_bool, c_int (GH-31) (#3242)
[2.7] bpo-10746: Fix ctypes PEP 3118 type codes for c_long, c_bool, c_int (GH-31)

Ctypes currently produces wrong pep3118 type codes for several types.
E.g. memoryview(ctypes.c_long()).format gives "<l" on 64-bit platforms,
but it should be "<q" instead for sizeof(c_long) == 8

The problem is that the '<>' endian specification in the struct syntax
also turns on the "standard size" mode, which makes type characters have
a platform-independent meaning, which does not match with the codes used
internally in ctypes.  The struct module format syntax also does not
allow specifying native-size non-native-endian items.

This commit adds a converter function that maps the internal ctypes
codes to appropriate struct module standard-size codes in the pep3118
format strings. The tests are modified to check for this..
(cherry picked from commit 07f1658aa0)
2017-09-02 18:24:32 +02:00
Oren Milman 20958e6d91 [2.7] bpo-31243: Fixed PyArg_ParseTuple failure checks. (GH-3171) (#3235) 2017-08-29 19:16:12 +03:00
Oren Milman bc80fd1bd2 [2.7] bpo-28261: Prevent raising SystemError where PyArg_ParseTuple is used to parse non-args. (#3213) 2017-08-26 21:56:31 +03:00
Victor Stinner ec4ab09b7c bpo-30947: Update libexpat from 2.2.1 to 2.2.3 (#3106) (#3145)
* bpo-30947: Update libexpat from 2.2.1 to 2.2.3

* Add NEWS entry

* Add new loadlibrary.c

* expat_external.h: restore include "pyexpatns.h"

* PCbuild: add expat/loadlibrary.c

* Define XML_POOR_ENTROPY to compile expat

Python 2.7 backport: add expat/loadlibrary.c to PC/VS9.0/ project
files (_elementtree and pyexpat).

(cherry picked from commit 93d0cb58b4)
2017-08-19 01:06:45 +02:00
Victor Stinner 4dea06531e bpo-31173: Rewrite WSTOPSIG test of test_subprocess (#3055) (#3071)
The current test_child_terminated_in_stopped_state() function test
creates a child process which calls ptrace(PTRACE_TRACEME, 0, 0) and
then crash (SIGSEGV). The problem is that calling os.waitpid() in the
parent process is not enough to close the process: the child process
remains alive and so the unit test leaks a child process in a
strange state. Closing the child process requires non-trivial code,
maybe platform specific.

Remove the functional test and replaces it with an unit test which
mocks os.waitpid() using a new _testcapi.W_STOPCODE() function to
test the WIFSTOPPED() path.
(cherry picked from commit 7b7c6dcfff)
2017-08-11 14:38:37 +02:00
Segev Finer 884c4ca33a [2.7] bpo-30797: Avoid _GNU_SOURCE redefined warning in xmlparse.c (GH-2670) (#2672)
* [2.7] Avoid _GNU_SOURCE redefined warning in xmlparse.c (GH-2670)
(cherry picked from commit f52325598e)

* [2.7] Avoid _GNU_SOURCE redefined warning in xmlparse.c (GH-2670).
(cherry picked from commit f52325598e)
2017-07-12 00:16:28 +02:00
Nir Soffer bfa4fe4f39 [2.7] bpo-29854: Fix segfault in call_readline() (GH-728)
If history-length is set in .inputrc, and the history file is double the
history size (or more), history_get(N) returns NULL, and python
segfaults. Fix that by checking for NULL return value.

It seems that the root cause is incorrect handling of bigger history in
readline, but Python should not segfault even if readline returns
unexpected value.

This issue affects only GNU readline. When using libedit emulation
system history size option does not work.

This is a backport of the actual fix from master without the test, since
the test depends on new run_pty() helper which is not available in 2.7.
2017-07-11 00:06:57 +03:00
Antoine Pitrou a45a99b47f [2.7] bpo-30807: signal.setitimer() may disable the timer by mistake (GH-2493) (#2499)
* bpo-30807: signal.setitimer() may disable the timer by mistake

* Add NEWS blurb.
(cherry picked from commit 729780a810)
2017-06-30 10:54:54 +02:00
Victor Stinner 95a91df036 bpo-30764: Windows support.SuppressCrashReport (#2423)
* Add Windows support to test.support.SuppressCrashReport: call
  SetErrorMode() and CrtSetReportMode().
* _testcapi: add CrtSetReportMode() and CrtSetReportFile() functions
  and CRT_xxx and CRTDBG_xxx constants needed by SuppressCrashReport.
2017-06-27 14:31:40 +02:00