Commit Graph

10600 Commits

Author SHA1 Message Date
Alexey Izbyshev 388bd4bd76 [3.7] bpo-34492: Modules/main.c: Fix copy_wstrlist() (GH-8910) (GH-8922)
* Add missing NULL check reported by Svace static analyzer.
* Fix clear_wstrlist() call on a wrong list.

(cherry picked from commit eb746dbae8)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-08-25 18:46:58 +02:00
Miss Islington (bot) d5f017bbd6
bpo-13312: Avoid int underflow in time year. (GH-8912)
Avoids an integer underflow in the time module's year handling code.
(cherry picked from commit 76be0fffff)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2018-08-25 01:53:00 -04:00
Miss Islington (bot) c7f5435201
closes bpo-34471: _datetime: Add missing NULL check to tzinfo_from_isoformat_results. (GH-8869)
Reported by Svace static analyzer.
(cherry picked from commit 498845368f)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-08-24 12:13:57 -04:00
Miss Islington (bot) 89b1654e0b
bpo-34454: fix .fromisoformat() methods crashing on inputs with surrogate code points (GH-8862)
The current C implementations **crash** if the input includes a surrogate
Unicode code point, which is not possible to encode in UTF-8.

Important notes:

1.  It is possible to pass a non-UTF-8 string as a separator to the
    `.isoformat()` methods.
2.  The pure-Python `datetime.fromisoformat()` implementation accepts
    strings with a surrogate as the separator.

In `datetime.fromisoformat()`, in the special case of non-UTF-8 separators,
this implementation will take a performance hit by making a copy of the
input string and replacing the separator with 'T'.

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
Co-authored-by: Paul Ganssle <paul@ganssle.io>
(cherry picked from commit 096329f0b2)

Co-authored-by: Paul Ganssle <pganssle@users.noreply.github.com>
2018-08-23 11:54:33 -04:00
Victor Stinner 80a0ebaa83
bpo-34207: Fix pymain_read_conf() for UTF-8 Mode (GH-8868) (GH-8870)
bpo-34170, bpo-34207: pymain_read_conf() now sets Py_UTF8Mode to
config->utf8_mode. pymain_read_conf() calls indirectly
Py_DecodeLocale() and Py_EncodeLocale() which depend on Py_UTF8Mode.

(cherry picked from commit 89487f51b8)
2018-08-23 12:41:35 +02:00
Miss Islington (bot) 3152bc36fd
bpo-34456: pickle: Add missing NULL check to save_global(). (GH-8851)
Reported by Svace static analyzer.
(cherry picked from commit f8c06b0280)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-08-22 01:54:33 -04:00
Miss Islington (bot) d1f0ccc7e6
bpo-34441: Fix ABC.__subclasscheck__ crash on classes with invalid __subclasses__ (GH-8835)
The missing NULL check was reported by Svace static analyzer.
(cherry picked from commit cdbf50cba1)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-08-20 16:42:18 -04:00
Miss Islington (bot) bf8e9d18dd
bpo-34217: Use lowercase for windows headers (GH-8472)
(cherry picked from commit e6a4755e67)

Co-authored-by: Erik Janssens <erik.janssens@conceptive.be>
2018-08-16 03:29:20 -04:00
Miss Islington (bot) 962051eeb0
bpo-34395: Fix memory leaks caused by incautious usage of PyMem_Resize(). (GH-8756)
(cherry picked from commit 67b9cc8e60)

Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
2018-08-16 00:53:00 -04:00
Victor Stinner 0c90d6f759
[3.7] bpo-34247: Fix Python 3.7 initialization (#8659)
* -X dev: it is now possible to override the memory allocator using
  PYTHONMALLOC even if the developer mode is enabled.
* Add _Py_InitializeFromConfig()
* Add _Py_Initialize_ReadEnvVars() to set global configuration
  variables from environment variables
* Fix the code to initialize Python: Py_Initialize() now also reads
  environment variables
* _Py_InitializeCore() can now be called twice: the second call
  only replaces the configuration.
* Write unit tests on Py_Initialize() and the different ways to
  configure Python
* The isolated mode now always sets Py_IgnoreEnvironmentFlag and
  Py_NoUserSiteDirectory to 1.
* pymain_read_conf() now saves/restores the configuration
  if the encoding changed
2018-08-05 12:31:59 +02:00
Miss Islington (bot) 28dbfb2fd3
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:30:49 -07:00
Miss Islington (bot) 3e4b688759
bpo-33871: Fix os.sendfile(), os.writev(), os.readv(), etc. (GH-7931)
* Fix integer overflow in os.readv(), os.writev(), os.preadv()
  and os.pwritev() and in os.sendfile() with headers or trailers
  arguments (on BSD-based OSes and MacOS).

* Fix sending the part of the file in os.sendfile() on MacOS.
  Using the trailers argument could cause sending more bytes from
  the input file than was specified.

Thanks Ned Deily for testing on 32-bit MacOS.
(cherry picked from commit 9d5727326a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-07-31 02:20:06 -07:00
Serhiy Storchaka 47957dab94
[3.7] bpo-33729: Fix issues with arguments parsing in hashlib. (GH-8346) (GH-8581)
* help(hashlib) didn't work because of incorrect module name in blake2b and
  blake2s classes.
* Constructors blake2*(), sha3_*(), shake_*() and keccak_*() incorrectly
  accepted keyword argument "string" for binary data, but documented as
  accepting the "data" keyword argument. Now this parameter is positional-only.
* Keyword-only parameters in blake2b() and blake2s() were not documented as
  keyword-only.
* Default value for some parameters of blake2b() and blake2s() was None,
  which is not acceptable value.
* The length argument for shake_*.digest() was wrapped out to 32 bits.
* The argument for shake_128.digest() and shake_128.hexdigest() was not
  positional-only as intended.
* TypeError messages for incorrect arguments in all constructors sha3_*(),
  shake_*() and keccak_*() incorrectly referred to sha3_224.

Also made the following enhancements:

* More accurately specified input and result types for strings, bytes and
  bytes-like objects.
* Unified positional parameter names for update() and constructors.
* Improved formatting.
(cherry picked from commit f1d36d8efa)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-07-31 10:22:44 +03:00
Miss Islington (bot) 6c89a9a4c7
bpo-34217: Use lowercase header for Windows (GH-8453)
(cherry picked from commit 6cf8255912)

Co-authored-by: erikjanss <erik.janssens@conceptive.be>
2018-07-29 23:15:51 -07:00
Steve Dower 6332de10c7
bpo-34231: PYTHONBREAKPOINT is not documented on python --help (GH-8475) 2018-07-29 12:17:49 +01:00
Miss Islington (bot) c3af73d580 bpo-30237: Output error when ReadConsole is canceled by CancelSynchronousIo. (GH-7911)
(cherry picked from commit ce75df3031)

Co-authored-by: ValeriyaSinevich <valeriya.sinevich@phystech.edu>
2018-07-29 10:32:02 +01:00
Miss Islington (bot) 973649342c bpo-29097: Forego fold detection on windows for low timestamp values (GH-2385) (GH-8466)
On Windows, passing a negative value to local results in an OSError because localtime_s on Windows does not support negative timestamps. Unfortunately this means that fold detection for timestamps between 0 and max_fold_seconds will result in this OSError since we subtract max_fold_seconds from the timestamp to detect a fold. However, since we know there haven't been any folds in the interval [0, max_fold_seconds) in any timezone, we can hackily just forego fold detection for this time range on Windows.
(cherry picked from commit 96d1e69a12)

Co-authored-by: Ammar Askar <ammar_askar@hotmail.com>
2018-07-25 16:34:09 -04:00
Miss Islington (bot) 03ec4df67d bpo-34008: Allow to call Py_Main() after Py_Initialize() (GH-8043) (GH-8352)
Py_Main() can again be called after Py_Initialize(), as in Python
3.6. The new configuration is ignored, except of
_PyMainInterpreterConfig.argv which is used to update sys.argv.
(cherry picked from commit fb47bca9ee)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2018-07-21 02:16:22 +02:00
Miss Islington (bot) 6020d98bea
bpo-34068: _io__IOBase_close_impl could call _PyObject_SetAttrId with an exception set (GH-8282)
(cherry picked from commit 28f07364f0)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-07-17 00:09:32 -07:00
Miss Islington (bot) c3bdea4c6c
prefix internal sqlite symbols with _pysqlite_ (GH-8215)
(cherry picked from commit 7762e4d387)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-07-09 21:48:02 -07:00
Miss Islington (bot) ba10da1373
delete some unused pysqlite forward declarations (GH-8211)
(cherry picked from commit d6d4432724)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-07-09 21:02:29 -07:00
Miss Islington (bot) 6d16a91200
Make PySimpleQueueType static. (GH-8175)
(cherry picked from commit 9b50a7f29b)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-07-07 15:42:28 -07:00
Miss Islington (bot) c34e4e987b
Make various internal _testbuffer symbols static. (GH-8160)
(cherry picked from commit 6cfe45a5c3)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-07-07 11:37:54 -07:00
Miss Islington (bot) 8e4c8513f7
Make two PyModuleDef_Slot symbols static in _testmultiphase. (GH-8147)
(cherry picked from commit cb4bae72c9)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-07-06 21:25:22 -07:00
Miss Islington (bot) 60214dd2d5
Make TaskStepMethWrapper_Type and TaskWakeupMethWrapper_Type static. (GH-8127)
(cherry picked from commit 3c8aae9ffe)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-07-05 22:58:27 -07:00
Miss Islington (bot) 2cbd1bb1f3
Make GenericAlias_Type and Generic_Type static. (GH-8076)
(cherry picked from commit 97ae32c92e)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-07-03 23:08:57 -07:00
Miss Islington (bot) 123f2b4540
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:50:34 -07:00
Miss Islington (bot) dedb28efd8
bpo-25862: Fix several bugs in the _io module. (GH-8026)
They can be exposed when some C API calls fail due to lack of
memory.

* Failed Py_BuildValue() could cause an assertion error in the
  following TextIOWrapper.tell().
* input_chunk could be decrefed twice in TextIOWrapper.seek()
  after failed Py_BuildValue().
* initvalue could leak in StringIO.__getstate__() after failed
  PyDict_Copy().
(cherry picked from commit fdb5a50ef3)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-06-30 11:25:37 -07:00
Miss Islington (bot) fd1c092bb9 bpo-32568: make select.epoll() and its docs consistent (GH-7840) (GH-8024)
* `flags` is indeed deprecated, but there is a validation on its value for
  backwards compatibility reasons.  This adds mention of this in the docs.
* The docs say that `sizehint` is deprecated and ignored, but it is still
  used when `epoll_create1()` is unavailable. This adds mention of this in
  the docs.
* `sizehint=-1` is acceptable again, and is replaced with `FD_SETSIZE-1`.
  This is needed to have a default value available at the Python level,
  since `FD_SETSIZE` is not exposed to Python. (see: bpo-31938)
* Reject `sizehint=0` since it is invalid to pass on to `epoll_create()`.

The relevant tests have also been updated.

(cherry picked from commit 0cdf5f4289)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
2018-06-30 16:03:19 +03:00
Miss Islington (bot) eabebbb54c
bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918)
(cherry picked from commit 23db935bcf)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-06-29 03:34:34 -07:00
Miss Islington (bot) fb17b81fc9
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 19:44:32 -07:00
Miss Islington (bot) efc6bf66a5
bpo-33916: Fix bz2 and lzma init when called twice (GH-7843)
bz2, lzma: When Decompressor.__init__() is called twice, free the old
lock to not leak memory.
(cherry picked from commit 9b7cf75721)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2018-06-23 01:53:03 -07:00
Miss Islington (bot) 046da16695
bpo-33824, bpo-32030: Fix pymain_read_conf() (GH-7712)
Fix "LC_ALL=C python3.7 -V": reset properly the command line parser
when the encoding changes after reading the Python configuration.

Fix pymain_read_conf(): use memset(0) to reset properly cmdline.
(cherry picked from commit 6c5a4b3156)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2018-06-15 15:26:29 -07:00
Miss Islington (bot) 0e2b76ea4e
bpo-29456: Fix bugs in unicodedata.normalize: u1176, u11a7 and u11c3 (GH-1958)
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 05:21:55 -07:00
Miss Islington (bot) 42198571c5 bpo-31432: Revert unrelated code changes to _ssl.c and test_ssl (GH-7650) (GH-7651)
(cherry picked from commit 4531ec74c4)

Co-authored-by: Ned Deily <nad@python.org>
2018-06-11 20:58:06 -04:00
Miss Islington (bot) a5db479ac4 bpo-31432: Clarify ssl CERT_NONE/OPTIONAL/REQUIRED docs. (GH-3530) (GH-7649)
The documentation for CERT_NONE, CERT_OPTIONAL, and CERT_REQUIRED were
misleading and partly wrong. It fails to explain that OpenSSL behaves
differently in client and server mode. Also OpenSSL does validate the
cert chain everytime. With SSL_VERIFY_NONE a validation error is not
fatal in client mode and does not request a client cert in server mode.
Also discourage people from using CERT_OPTIONAL in client mode.
(cherry picked from commit ef24b6c54d)

Co-authored-by: Christian Heimes <christian@python.org>
2018-06-11 19:20:24 -04:00
Miss Islington (bot) 037e912552 bpo-33812: Corrected astimezone for naive datetimes. (GH-7578) (GH-7600)
A datetime object d is aware if d.tzinfo is not None and
d.tzinfo.utcoffset(d) does  not return None. If d.tzinfo is None,
or if d.tzinfo is not None but d.tzinfo.utcoffset(d) returns None,
 d is naive.

This commit ensures that instances with non-None d.tzinfo, but
d.tzinfo.utcoffset(d) returning None are treated as naive.

In addition, C acceleration code will raise TypeError if
d.tzinfo.utcoffset(d) returns an object with the type other than
timedelta.

* Updated the documentation.

Assume that the term "naive" is defined elsewhere and remove the
not entirely correct clarification.  Thanks, Tim.
(cherry picked from commit 877b23202b)

Co-authored-by: Alexander Belopolsky <abalkin@users.noreply.github.com>
2018-06-10 18:02:24 -04:00
Miss Islington (bot) 053d6c5ce2 bpo-33770: improve base64 exception message for encoded inputs of invalid length (GH-7416) (GH-7602)
(cherry picked from commit 1b85c71a21)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
2018-06-10 17:37:14 -04:00
Miss Islington (bot) 4705ea38c9 update to Unicode 11.0.0 (closes bpo-33778) (GH-7439) (GH-7470)
Also, standardize indentation of generated tables.
(cherry picked from commit 7c69c1c0fb)

Co-authored-by: Benjamin Peterson <benjamin@python.org>
2018-06-07 03:36:22 -04:00
Miss Islington (bot) 5c022f13ab
bpo-33781: audioop: enhance rounding double as int (GH-7447)
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)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2018-06-06 07:33:05 -07:00
Miss Islington (bot) 631fe1fa42
bpo-33767: Fix improper use of SystemError by mmap.mmap objects (GH-7381)
Raise TypeError instead of SystemError for unsupported operations.
(cherry picked from commit e9e3976057)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-06-05 06:21:04 -07:00
Miss Islington (bot) 623b439abe bpo-30654: Do not reset SIGINT handler to SIG_DFL in finisignal (GH-7146) (GH-7306)
(cherry picked from commit e905c84494)

Co-authored-by: pkerling <pkerling@casix.org>
2018-06-01 12:50:24 +02:00
Miss Islington (bot) c6de46e180
bpo-33706: Fix pymain_parse_cmdline_impl() (GH-7283)
Fix a crash in Python initialization when parsing the command line
options.

Fix memcpy() size parameter: previously, we read one wchar_t after
the end of _PyOS_optarg. Moreover, don't copy the trailingg NUL
character: we write it manually anyway.

Thanks Christoph Gohlke for the bug report and the fix!
(cherry picked from commit 58d1683255)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2018-05-31 06:43:21 -07:00
Miss Islington (bot) a4dd46a47f
bpo-33677: Fix signatures of tp_clear handlers for AST and deque. (GH-7196)
(cherry picked from commit a5c42284e6)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-05-30 22:31:21 -07:00
Miss Islington (bot) ddc613f203
bpo-32610: Fix asyncio.all_tasks() to return only pending tasks. (GH-7174)
(cherry picked from commit 416c1ebd98)

Co-authored-by: Yury Selivanov <yury@magic.io>
2018-05-28 17:16:43 -07:00
Miss Islington (bot) 51d0a2c8dd
bpo-33623: Fix possible SIGSGV when asyncio.Future is created in __del__ (GH-7080)
(cherry picked from commit 35230d08e0)

Co-authored-by: Yury Selivanov <yury@magic.io>
2018-05-28 08:28:12 -07:00
Miss Islington (bot) e60f6e1864
bpo-21983: Fix a crash in ctypes.cast() when passed a ctypes structured data type (GH-3859)
(cherry picked from commit d518d8bc8d)

Co-authored-by: Oren Milman <orenmn@gmail.com>
2018-05-26 11:39:52 -07:00
Miss Islington (bot) 14d289be60
bpo-33644: Fix signatures of tp_finalize handlers in testing code. (GH-7111)
(cherry picked from commit 19de8b3dd7)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-05-26 01:33:23 -07:00
Miss Islington (bot) 5734f41a9b
bpo-32493: Fix uuid.uuid1() on FreeBSD. (GH-7099)
Use uuid_enc_be() if available to encode UUID to bytes as big endian.
(cherry picked from commit 17d8830312)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-05-24 16:22:59 -07:00
Miss Islington (bot) 2fe940c727
bpo-33622: Fix issues with handling errors in the GC. (GH-7078)
* 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.
* Fixed an undefined behavior with comparing a dead pointer with NULL.
(cherry picked from commit 301e3cc8a5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-05-24 05:39:08 -07:00