Commit Graph

10679 Commits

Author SHA1 Message Date
Miss Islington (bot) 265b41996a
bpo-35371: Fix possible crash in os.utime() on Windows. (GH-10844)
(cherry picked from commit 32bc11c33c)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-12-01 04:52:04 -08:00
Victor Stinner 38c06d9193
get_gmtoff() now returns time_t (GH-10838) (GH-10839)
get_gmtoff() now returns time_t instead of int to fix the following
Visual Studio warning:

    Modules\timemodule.c(1183): warning C4244: 'return':
    conversion from 'time_t' to 'int', possible loss of data

(cherry picked from commit 503ce5c482)
2018-12-01 01:24:21 +01:00
Victor Stinner df738d56fe
bpo-35336: Fix PYTHONCOERCECLOCALE=1 (GH-10806) (GH-10813)
Fix PYTHONCOERCECLOCALE=1 environment variable: only coerce the C
locale if the LC_CTYPE locale is "C".

(cherry picked from commit 55e498058f)
2018-11-30 12:19:48 +01:00
Miss Islington (bot) e604b6c53e
bpo-35356: Fix a possible reference leak in nis.maps(). (GH-10808)
(cherry picked from commit a2e3585e79)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-11-30 00:00:07 -08:00
Serhiy Storchaka ad8ac54aa3
bpo-33012: Fix signatures of METH_NOARGS functions. (GH-10736) (GH-10748)
(cherry picked from commit 81524022d0)
2018-11-27 20:27:47 +02:00
Miss Islington (bot) 5ceb7018dc
bpo-33029: Fix signatures of getter and setter functions. (GH-10746)
Fix also return type for few other functions (clear, releasebuffer).
(cherry picked from commit d4f9cf5545)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-11-27 09:58:07 -08:00
Miss Islington (bot) 716a8089b0
closes bpo-34212: Build core extension modules with Py_BUILD_CORE_BUILTIN. (GH-8712)
(cherry picked from commit da324d53d4)

Co-authored-by: E. M. Bray <erik.m.bray@gmail.com>
2018-11-26 18:32:57 -08:00
Miss Islington (bot) bc665b42ba
bpo-35303: Fix a reference leak in _operator.c's methodcaller_repr(). (GH-10689)
(cherry picked from commit 5b83ef71d3)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-11-23 11:58:08 -08:00
Victor Stinner 56742f1eb0
[3.7] bpo-35189: Retry fnctl calls on EINTR (GH-10413) (GH-10678)
* bpo-35189: Fix eintr_tester.py (GH-10637)

Call setitimer() before each test method, instead of once per test
case, to ensure that signals are sent in each test method.
Previously, only the first method of a testcase class got signals.

Changes:

* Replace setUpClass() with setUp() and replace tearDownClass() with
  tearDown().
* tearDown() now ensures that at least one signal has been sent.
* Replace support.run_unittest() with unittest.main() which has
  a nicer CLI and automatically discover test cases.

(cherry picked from commit aac1f81eef)

* bpo-35189: Retry fnctl calls on EINTR (GH-10413)

Modify the following fnctl function to retry if interrupted by a signal
(EINTR): flock, lockf, fnctl.

(cherry picked from commit b409ffa848)
Co-Authored-By: nierob <nierob@users.noreply.github.com>
2018-11-23 17:53:14 +01:00
Miss Islington (bot) 18f3327d9a
bpo-24658: os.read() reuses _PY_READ_MAX (GH-10657)
os_read_impl() now also truncates the size to _PY_READ_MAX
on macOS, to avoid to allocate a larger buffer even if _Py_read() is
limited to _PY_READ_MAX bytes (ex: INT_MAX on macOS).
(cherry picked from commit 9a0d7a7648)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2018-11-22 06:17:34 -08:00
Victor Stinner 6eff6b8eec
bpo-28604: Fix localeconv() for different LC_MONETARY (GH-10606) (GH-10619)
locale.localeconv() now sets temporarily the LC_CTYPE locale to the
LC_MONETARY locale if the two locales are different and monetary
strings are non-ASCII. This temporary change affects other threads.

Changes:

* locale.localeconv() can now set LC_CTYPE to LC_MONETARY to decode
  monetary fields.
* Add LocaleInfo.grouping_buffer: copy localeconv() grouping string
  since it can be replaced anytime if a different thread calls
  localeconv().

(cherry picked from commit 02e6bf7f20)
2018-11-20 22:06:21 +01:00
Miss Islington (bot) d57ab8ac18
bpo-35021: Fix assertion failures in _datetimemodule.c. (GH-10039)
Fixes assertion failures in _datetimemodule.c
introduced in the previous fix (see bpo-31752).

Rather of trying to handle an int subclass as exact int,
let it to use overridden special methods, but check the
result of divmod().
(cherry picked from commit 3ec0f49516)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-11-20 10:59:12 -08:00
Steve Dower e851049e0e
bpo-34725: Adds _Py_SetProgramFullPath so embedders may override sys.executable (GH-9861) 2018-11-17 20:42:08 -08:00
Miss Islington (bot) b5ea5e57f5
Fix a possible reference leak in _socket.getaddrinfo(). (GH-10543)
"single" needs to be decrefed if PyList_Append() fails.
(cherry picked from commit 4c596d54aa)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-11-15 01:25:34 -08:00
Victor Stinner 9ee1d42f01
bpo-35233: InitConfigTests tests more config vars (GH-10541) (GH-10546)
test_embed.InitConfigTests tests more configuration variables.

Changes:

* InitConfigTests tests more core configuration variables:

  * base_exec_prefix
  * base_prefix
  * exec_prefix
  * home
  * module_search_path_env
  * prefix

* "_testembed init_from_config" tests more variables:

  * argv
  * warnoptions
  * xoptions

* Py_HasFileSystemDefaultEncoding value is no longer tested since it
  depends on the LC_CTYPE locale and the platform.
* InitConfigTests: add check_global_config(), check_core_config() and
  check_main_config() subfunctions to cleanup the code. Move also
  constants at the class level (ex: COPY_MAIN_CONFIG).
* Use more macros in _PyCoreConfig_AsDict() and
  _PyMainInterpreterConfig_AsDict() to reduce code duplication.
* Other minor cleanups.

(cherry picked from commit 01de89cb59)
2018-11-14 18:58:01 +01:00
Victor Stinner 88cbea4c6f
bpo-35233: Fix _PyMainInterpreterConfig_Copy() (GH-10537)
Fix _PyMainInterpreterConfig_Copy(): copy 'install_signal_handlers'
attribute
2018-11-14 02:45:25 +01:00
Victor Stinner 35c28d562e
[3.7] bpo-35233: Rewrite test_embed.InitConfigTests (GH-10524) (GH-10529)
* Add C functions:

  * _Py_GetGlobalVariablesAsDict()
  * _PyCoreConfig_AsDict()
  * _PyMainInterpreterConfig_AsDict()

* Add new _testcapi methods:

  * get_global_config()
  * get_core_config()
  * get_main_config()

* test.pythoninfo: get global, core and main configuration
* _testembed now serializes global, core and main configurations
  using JSON to reuse _Py_GetGlobalVariablesAsDict(),
  _PyCoreConfig_AsDict() and _PyMainInterpreterConfig_AsDict(),
  rather than duplicating code.
* test_embed.InitConfigTests now test much more configuration
  variables
2018-11-14 02:01:52 +01:00
Victor Stinner d57a3e5d03
bpo-29564:_PyMem_DumpTraceback() suggests enabling tracemalloc (GH-10510) (GH-10517)
If tracemalloc is not tracing Python memory allocations,
_PyMem_DumpTraceback() now suggests to enable tracemalloc
to get the traceback where the memory block has been allocated.
2018-11-13 15:50:56 +01:00
Miss Islington (bot) f6602f9266
bpo-35214: Add _Py_ prefix to MEMORY_SANITIZER def. (GH-10503)
Rename our new MEMORY_SANITIZER define to _Py_MEMORY_SANITIZER.
Project based C Preprocessor namespacing at its finest. :P
(cherry picked from commit 3015fb8ce4)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2018-11-12 22:20:21 -08:00
Gregory P. Smith 5f4d05d83f
[3.7] bpo-35214: Initial clang MemorySanitizer support (GH-10479) (GH-10492)
Adds configure flags for msan and ubsan builds to make it easier to enable.
These also encode the detail that address sanitizer and memory sanitizer
should disable pymalloc.

Define MEMORY_SANITIZER when appropriate at build time and adds workarounds
to existing code to mark things as initialized where the sanitizer is otherwise unable to
determine that.  This lets our build succeed under the memory sanitizer.  not all tests
pass without sanitizer failures yet but we're in pretty good shape after this.

(cherry picked from commit 1584a00815)

Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
2018-11-12 13:48:24 -08:00
Miss Islington (bot) 22234f1375
bpo-35194: Fix a wrong constant in cp932 codec (GH-10420)
This typo doesn't affect the result because wrong bits are discarded
on implicit conversion to unsigned char, but it trips UBSan
with -fsanitize=implicit-integer-truncation.

https://bugs.python.org/issue35194
(cherry picked from commit 7a69cf47a9)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-11-08 23:35:05 -08:00
Miss Islington (bot) 7beb8c54ed
bpo-35133: Fix mistakes when concatenate string literals on different lines. (GH-10284)
Two kind of mistakes:

1. Missed space. After concatenating there is no space between words.

2. Missed comma. Causes unintentional concatenating in a list of strings.
(cherry picked from commit 34fd4c2019)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-11-05 06:52:58 -08:00
BNMetrics 08026b103e [3.7]bpo-29341: Backport b942707 3.7 (#10298)
Some methods in the os module can accept path-like objects. This is documented in the general documentation but not in the function docstrings. To keep both in sync, the docstrings need to be updated to reflect that path-like objects are also accepted..
(cherry picked from commit b942707fc2)

Co-authored-by: BNMetrics <luna@bnmetrics.com>
2018-11-02 13:56:25 -04:00
Miss Islington (bot) 04c96669b1
closes bpo-35139: The `pyexpat` module's macros in `Modules/Setup` now match `setup.py` (GH-10289)
This could cause compile errors on macOS or other platforms.
(cherry picked from commit 318ab63c01)

Co-authored-by: Max Bélanger <aeromax@gmail.com>
2018-11-01 20:09:04 -07:00
Miss Islington (bot) 71b6c1af72
bpo-35062: Fix parsing _io.IncrementalNewlineDecoder's *translate* argument. (GH-10217)
_io.IncrementalNewlineDecoder's initializer possibly assigns out-of-range
value to the bitwise struct field.
(cherry picked from commit b08746bfdf)

Co-authored-by: Xiang Zhang <angwerzx@126.com>
2018-10-31 05:36:20 -07:00
Miss Islington (bot) f00703d294
Fix a possible "double decref" in termios.tcgetattr(). (GH-10194)
(cherry picked from commit 53835e92d3)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-10-28 22:17:45 -07:00
Miss Islington (bot) 1d7d165e3c
bpo-35090: Fix potential division by zero in allocator wrappers (GH-10174)
* Fix potential division by zero in BZ2_Malloc()
* Avoid division by zero in PyLzma_Malloc()
* Avoid division by zero and integer overflow in PyZlib_Malloc()

Reported by Svace static analyzer.
(cherry picked from commit 3d4fabb2a4)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-10-28 13:46:56 -07:00
Miss Islington (bot) 95cfb818ea
bpo-35059, libmpdec: Add missing EXTINLINE in mpdecimal.h (GH-10128)
Declare functions with EXTINLINE:

* mpd_del()
* mpd_uint_zero()
* mpd_qresize()
* mpd_qresize_zero()
* mpd_minalloc()

These functions are implemented with "inline" or "ALWAYS_INLINE", but
declared without inline which cause linker error on Visual Studio in
Debug mode when using /Ob1.
(cherry picked from commit 3b1cba3701)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
2018-10-26 10:28:26 -07:00
Miss Islington (bot) f7cefb427c bpo-34794: Fix a leak in Tkinter. (GH-10025) (GH-10069)
Based on the investigation by Xiang Zhang.
(cherry picked from commit df13df41a2)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-10-23 23:46:32 +02:00
Miss Islington (bot) c46f0423a4
Fix error handling bugs in _elementtree.c. (GH-10060)
References could leak, NULL could be dereferenced, and the Expat parser could
be double freed when some errors raised.
(cherry picked from commit 9f3ed3e213)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-10-23 12:45:44 -07:00
Miss Islington (bot) 18450be94d
bpo-34454: Clean up datetime.fromisoformat surrogate handling (GH-8959)
* Use _PyUnicode_Copy in sanitize_isoformat_str

* Use repr in fromisoformat error message

This reverses commit 67b74a98b2 per Serhiy Storchaka's suggestion:

     I suggested to use %R in the error message because including the raw
     string can be confusing in the case of empty string, or string
     containing trailing whitespaces, invisible or unprintable characters.

We agree that it is better to change both the C and pure Python versions
to use repr.

* Retain non-sanitized dtstr for error printing

This does not create an extra string, it just holds on to a reference to
the original input string for purposes of creating the error message.

* PEP 7 fixes to from_isoformat

* Separate handling of Unicode and other errors

In the initial implementation, errors other than encoding errors would
both raise an error indicating an invalid format, which would not be
true for errors like MemoryError.

* Drop needs_decref from _sanitize_isoformat_str

Instead _sanitize_isoformat_str returns a new reference, even to the
original string.
(cherry picked from commit 3df85404d4)

Co-authored-by: Paul Ganssle <pganssle@users.noreply.github.com>
2018-10-22 15:35:15 -07:00
Miss Islington (bot) 002aef3f66
closes bpo-35025: Properly guard the `CLOCK_GETTIME` et al macros in timemodule.c. (GH-9961)
Guard the `CLOCK_GETTIME` et al macros in `timemodule` based on the availability of the parent functions
(cherry picked from commit 94451182cc)

Co-authored-by: Max Bélanger <aeromax@gmail.com>
2018-10-20 17:41:38 -07:00
Miss Islington (bot) 8f53dcdb24
bpo-32890, os: Use errno instead of GetLastError() in execve() and truncate() (GH-5784)
path_error() uses GetLastError() on Windows, but some os functions
are implemented via CRT APIs which report errors via errno.
This may result in raising OSError with invalid error code (such
as zero).

Introduce posix_path_error() function and use it where appropriate.
(cherry picked from commit 834603112e)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2018-10-19 17:46:25 -07:00
Miss Islington (bot) 23efe77acf bpo-20216: Correct docstrings of digest() methods in hashlib. (GH-9873) (GH-9971)
(cherry picked from commit f192aeb95a)

Co-authored-by: Srinivas  Thatiparthy (శ్రీనివాస్  తాటిపర్తి) <srinivasreddy@users.noreply.github.com>
2018-10-20 01:20:56 +02:00
Miss Islington (bot) 4ec9f64e07 bpo-34824: Fix a possible NULL pointer dereference in _ssl.c (GH-9606) (GH-9743)
On failure, _PyBytes_Resize() will deallocate the bytes object and set
"result" to NULL.

https://bugs.python.org/issue34824
(cherry picked from commit 365ad2ead5)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-10-20 01:14:42 +02:00
Miss Islington (bot) ef7f29f66c
Elaborate datetime.timedelta docstring (GH-7458)
(cherry picked from commit d6a61f2326)

Co-authored-by: Chris Barker <Chris.Barker@noaa.gov>
2018-10-19 16:02:13 -07:00
Miss Islington (bot) d6d35d0a00
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:16:25 -07:00
Miss Islington (bot) 5b9b9353de
bpo-35008: Fix possible leaks in Element.__setstate__(). (GH-9924)
C implementation of xml.etree.ElementTree.Element.__setstate__()
leaked references to children when called for already initialized
element.
(cherry picked from commit 6f906b3d72)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-10-18 00:17:15 -07:00
Miss Islington (bot) 178d1c0777
bpo-24658: Fix read/write greater than 2 GiB on macOS (GH-1705)
On macOS, fix reading from and writing into a file with a size larger than 2 GiB.
(cherry picked from commit 74a8b6ea7e)

Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
2018-10-17 23:58:40 -07:00
Miss Islington (bot) 35ae99d7b3
[3.7] bpo-35011: Restore use of pyexpatns.h in libexpat (GH-9939) (GH-9940)
Restores the use of pyexpatns.h to isolate our embedded copy of the expat C
library so that its symbols do not conflict at link or dynamic loading time
with an embedding application or other extension modules with their own
version of libexpat.

5dc3f23b5fGH-diff-3afaf7274c90ce1b7405f75ad825f545 inadvertently removed it when upgrading expat.
(cherry picked from commit 9d4712bc8f)


Co-authored-by: Gregory P. Smith <greg@krypto.org>


https://bugs.python.org/issue35011
2018-10-17 19:06:30 -07:00
Miss Islington (bot) b1c800303e
bpo-34941: Fix searching Element subclasses. (GH-9766)
Methods find(), findtext() and findall() of xml.etree.ElementTree.Element
were not able to find chldren which are instances of Element subclasses.
(cherry picked from commit b11c5667f9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2018-10-14 00:55:49 -07:00
Serhiy Storchaka 8b040e5539
[3.7] bpo-34922: Fix integer overflow in the digest() and hexdigest() methods (GH-9751) (GH-9798)
for the SHAKE algorithm in the hashlib module.
(cherry picked from commit 9b8c2e7676)
2018-10-11 08:06:36 +03:00
Stéphane Wirtel a4910c2498 [3.7] bpo-34906: Doc: Fix typos (2) (GH-9735)
(cherry picked from commit 683281f536)
2018-10-10 15:39:17 +02:00
Serhiy Storchaka d9212200fe
[3.7] Fix a compiler warning added in bpo-34872. (GH-9722). (GH-9726)
(cherry picked from commit addf8afb43)
2018-10-05 21:58:15 +03:00
Miss Islington (bot) b3c4a050b7
bpo-34906: Doc: Fix typos (GH-9712)
(cherry picked from commit 07fbbfde1b)

Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
2018-10-05 07:35:18 -07:00
Elvis Pranskevichus a67bd53d3f [3.7] bpo-34872: Fix self-cancellation in C implementation of asyncio.Task (GH-9679) (GH-9691)
The C implementation of asyncio.Task currently fails to perform the
cancellation cleanup correctly in the following scenario.

    async def task1():
        async def task2():
            await task3     # task3 is never cancelled

        asyncio.current_task().cancel()
        await asyncio.create_task(task2())

The actuall error is a hardcoded call to `future_cancel()` instead of
calling the `cancel()` method of a future-like object.

Thanks to Vladimir Matveev for noticing the code discrepancy and to
Yury Selivanov for coming up with a pathological scenario..
(cherry picked from commit 548ce9dedd)

Co-authored-by: Elvis Pranskevichus <elvis@magic.io>


https://bugs.python.org/issue34872
2018-10-03 08:49:00 -07:00
Miss Islington (bot) 758ad54dac
Fix incorrect error handling in _pickle.Unpickler.__init__() (GH-9630)
_pickle.Unpickler.__init__() should return -1 if Pdata_New() fails, not 1.
(cherry picked from commit 4b430e5f69)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2018-09-28 23:01:48 -07:00
Miss Islington (bot) 7e35081bc8
bpo-34736: improve error message for invalid length b64decode inputs (GH-9563)
Improvements:
1. Include the number of valid data characters in the error message.
2. Mention "number of data characters" rather than "length".

https://bugs.python.org/issue34736
(cherry picked from commit 1fba2ffc37)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
2018-09-27 23:12:54 -07:00
Yury Selivanov 24cb7de15d
[3.7] bpo-34762: Update PyContext* refs to PyObject* in asyncio and decimal (GH-9610) 2018-09-27 15:33:23 -04:00
Victor Stinner ddc163df25
bpo-34783: Fix Py_Main() (GH-9526)
Fix a crash with musl libc (on Alpine Linux) when the script filename
specified on the command line doesn't exist. pymain_open_filename()
now gets the current core configuration from the interpreter state.

Modify the code to make it closer to the master branch:

* Rename _Py_CommandLineDetails to _PyCmdline
* Remove _PyMain.config: replaced with a local variable
  'local_config' in pymain_init()
* Reorganize pymain_main(): move code using the "local config"
  into pymain_init()
* As soon as possible, switch from the local config to the core
  configuration attached to the interpreter.
2018-09-24 05:03:01 -07:00