summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
Commit message (Collapse)AuthorAgeFilesLines
* [3.7] bpo-37170: Fix the cast on error in PyLong_AsUnsignedLongLongMask() ↵Zackery Spytz2019-06-071-0/+22
| | | | | | | (GH-13860) (GH-13896) (cherry picked from commit dc2476500d91082f0c907772c83a044bf49af279) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* [3.7] bpo-36389: _PyObject_IsFreed() now also detects uninitialized memory ↵Victor Stinner2019-04-111-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | (GH-12770) (GH-12788) * bpo-36389: _PyObject_IsFreed() now also detects uninitialized memory (GH-12770) Replace _PyMem_IsFreed() function with _PyMem_IsPtrFreed() inline function. The function is now way more efficient, it became a simple comparison on integers, rather than a short loop. It detects also uninitialized bytes and "forbidden bytes" filled by debug hooks on memory allocators. Add unit tests on _PyObject_IsFreed(). (cherry picked from commit 2b00db68554422ec37faba2a80179a0172df6349) * bpo-36389: Change PyMem_SetupDebugHooks() constants (GH-12782) Modify CLEANBYTE, DEADDYTE and FORBIDDENBYTE constants: use 0xCD, 0xDD and 0xFD, rather than 0xCB, 0xBB and 0xFB, to use the same byte patterns than Windows CRT debug malloc() and free(). (cherry picked from commit 4c409beb4c360a73d054f37807d3daad58d1b567)
* bpo-36436: Fix _testcapi.pymem_buffer_overflow() (GH-12560)Miss Islington (bot)2019-03-261-0/+4
| | | | | | Handle memory allocation failure. (cherry picked from commit 414b1cde93764cdabb0798b02af4dd7df954424d) Co-authored-by: Victor Stinner <vstinner@redhat.com>
* bpo-33012: Fix signatures of METH_NOARGS functions. (GH-10736) (GH-10748)Serhiy Storchaka2018-11-271-5/+5
| | | | (cherry picked from commit 81524022d0c0df7a41f9b2b2df41e2ebe140e610)
* [3.7] bpo-35233: Rewrite test_embed.InitConfigTests (GH-10524) (GH-10529)Victor Stinner2018-11-141-0/+28
| | | | | | | | | | | | | | | | | | | | | * 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
* Make GenericAlias_Type and Generic_Type static. (GH-8076)Miss Islington (bot)2018-07-041-2/+2
| | | | | (cherry picked from commit 97ae32c92ecc7b3c29f8829a2b79f0f8f8bbf2cc) Co-authored-by: Benjamin Peterson <benjamin@python.org>
* Don't export pending_threadfunc from _testcapi. (GH-8075)Miss Islington (bot)2018-07-041-1/+2
| | | | | (cherry picked from commit b4588c2fffbda91e4c2f0cf2b0fc3d14def95608) Co-authored-by: Benjamin Peterson <benjamin@python.org>
* Test that new_timezone can return the UTC singleton (gh-5318) (#5819)Miss Islington (bot)2018-02-221-0/+24
| | | | | (cherry picked from commit a049f5790e38fe1b1ba1d4c10ed5ab35150806fa) Co-authored-by: Paul Ganssle <pganssle@users.noreply.github.com>
* Cleanup dangling reference in get_timezone_utc_capi (#5317)Paul Ganssle2018-01-251-0/+2
|
* bpo-10381: Add timezone to datetime C API (#5032)Paul Ganssle2018-01-241-0/+87
| | | | | | | | | | | | | | | | | | * Add timezone to datetime C API * Add documentation for timezone C API macros * Add dedicated tests for datetime type check macros * Remove superfluous C API test * Drop support for TimeZoneType in datetime C API * Expose UTC singleton to the datetime C API * Update datetime C-API documentation to include links * Add reference count information for timezone constructors
* bpo-32436: Implement PEP 567 (#5027)Yury Selivanov2018-01-231-0/+8
|
* bpo-32226: Fix memory leak in generic_alias_dealloc() (#5212)Victor Stinner2018-01-171-0/+1
|
* bpo-32226: Make __class_getitem__ an automatic class method. (#5098)Serhiy Storchaka2018-01-041-6/+2
|
* Add tests for using PEP560 with classes implemented in C. (#4883)Serhiy Storchaka2017-12-161-0/+85
| | | Based on tests from #4878
* bpo-32030: Rework memory allocators (#4625)Victor Stinner2017-11-291-0/+19
| | | | | | | | | | | | | | | | | | | | * Fix _PyMem_SetupAllocators("debug"): always restore allocators to the defaults, rather than only caling _PyMem_SetupDebugHooks(). * Add _PyMem_SetDefaultAllocator() helper to set the "default" allocator. * Add _PyMem_GetAllocatorsName(): get the name of the allocators * main() now uses debug hooks on memory allocators if Py_DEBUG is defined, rather than calling directly malloc() * Document default memory allocators in C API documentation * _Py_InitializeCore() now fails with a fatal user error if PYTHONMALLOC value is an unknown memory allocator, instead of failing with a fatal internal error. * Add new tests on the PYTHONMALLOC environment variable * Add support.with_pymalloc() * Add the _testcapi.WITH_PYMALLOC constant and expose it as support.with_pymalloc(). * sysconfig.get_config_var('WITH_PYMALLOC') doesn't work on Windows, so replace it with support.with_pymalloc(). * pythoninfo: add _testcapi collector for pymem
* Add the const qualifier to "char *" variables that refer to literal strings. ↵Serhiy Storchaka2017-11-111-1/+1
| | | | (#4370)
* bpo-31784: Implement PEP 564: add time.time_ns() (#3989)Victor Stinner2017-11-021-21/+40
| | | | | | | | | | | | | | | | | | | | | | | | | Add new time functions: * time.clock_gettime_ns() * time.clock_settime_ns() * time.monotonic_ns() * time.perf_counter_ns() * time.process_time_ns() * time.time_ns() Add new _PyTime functions: * _PyTime_FromTimespec() * _PyTime_FromNanosecondsObject() * _PyTime_FromTimeval() Other changes: * Add also os.times() tests to test_os. * pytime_fromtimeval() and pytime_fromtimeval() now return _PyTime_MAX or _PyTime_MIN on overflow, rather than undefined behaviour * _PyTime_FromNanoseconds() parameter type changes from long long to _PyTime_t
* bpo-18835: Cleanup pymalloc (#4200)Victor Stinner2017-10-311-7/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | Cleanup pymalloc: * Rename _PyObject_Alloc() to pymalloc_alloc() * Rename _PyObject_FreeImpl() to pymalloc_free() * Rename _PyObject_Realloc() to pymalloc_realloc() * pymalloc_alloc() and pymalloc_realloc() don't fallback on the raw allocator anymore, it now must be done by the caller * Add "success" and "failed" labels to pymalloc_alloc() and pymalloc_free() * pymalloc_alloc() and pymalloc_free() don't update num_allocated_blocks anymore: it should be done in the caller * _PyObject_Calloc() is now responsible to fill the memory block allocated by pymalloc with zeros * Simplify pymalloc_alloc() prototype * _PyObject_Realloc() now calls _PyObject_Malloc() rather than calling directly pymalloc_alloc() _PyMem_DebugRawAlloc() and _PyMem_DebugRawRealloc(): * document the layout of a memory block * don't increase the serial number if the allocation failed * check for integer overflow before computing the total size * add a 'data' variable to make the code easiler to follow test_setallocators() of _testcapimodule.c now test also the context.
* bpo-30697: Fix PyErr_NormalizeException() when no memory (GH-2327)xdegaye2017-10-261-0/+63
|
* bpo-31786: Make functions in the select module blocking when timeout is a ↵Pablo Galindo2017-10-171-1/+2
| | | | small negative value. (#4003)
* bpo-28280: Make PyMapping_Keys(), PyMapping_Values() and PyMapping_Items() ↵Oren Milman2017-10-081-0/+22
| | | | always return a list (#3840)
* bpo-25658: Implement PEP 539 for Thread Specific Storage (TSS) API (GH-1362)Masayuki Yamamoto2017-10-061-0/+56
| | | | | | | | | See PEP 539 for details. Highlights of changes: - Add Thread Specific Storage (TSS) API - Document the Thread Local Storage (TLS) API as deprecated - Update code that used TLS API to use TSS API
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-11/+0
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-31243: Fixed PyArg_ParseTuple failure checks. (#3171)Oren Milman2017-08-291-16/+30
|
* bpo-31173: Rewrite WSTOPSIG test of test_subprocess (#3055)Victor Stinner2017-08-101-0/+22
| | | | | | | | | | | | | 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.
* bpo-30866: Add _testcapi.stack_pointer() (#2601)Victor Stinner2017-07-101-0/+8
|
* bpo-30695: Add set_nomemory(start, stop) to _testcapi (GH-2406)xdegaye2017-07-011-0/+128
|
* bpo-30054: Expose tracemalloc C API (#1236)Victor Stinner2017-06-201-5/+5
| | | | | | | | | * Make PyTraceMalloc_Track() and PyTraceMalloc_Untrack() functions public (remove the "_" prefix) * Remove the _PyTraceMalloc_domain_t type: use directly unsigned int. * Document methods Note: methods are already tested in test_tracemalloc.
* bpo-30524: Write unit tests for FASTCALL (#2022)Victor Stinner2017-06-091-0/+101
| | | | | | | Test C functions: * _PyObject_FastCall() * _PyObject_FastCallDict() * _PyObject_FastCallKeywords()
* bpo-30039: Don't run signal handlers while resuming a yield from stack (#1081)Nathaniel J. Smith2017-05-171-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we have a chain of generators/coroutines that are 'yield from'ing each other, then resuming the stack works like: - call send() on the outermost generator - this enters _PyEval_EvalFrameDefault, which re-executes the YIELD_FROM opcode - which calls send() on the next generator - which enters _PyEval_EvalFrameDefault, which re-executes the YIELD_FROM opcode - ...etc. However, every time we enter _PyEval_EvalFrameDefault, the first thing we do is to check for pending signals, and if there are any then we run the signal handler. And if it raises an exception, then we immediately propagate that exception *instead* of starting to execute bytecode. This means that e.g. a SIGINT at the wrong moment can "break the chain" – it can be raised in the middle of our yield from chain, with the bottom part of the stack abandoned for the garbage collector. The fix is pretty simple: there's already a special case in _PyEval_EvalFrameEx where it skips running signal handlers if the next opcode is SETUP_FINALLY. (I don't see how this accomplishes anything useful, but that's another story.) If we extend this check to also skip running signal handlers when the next opcode is YIELD_FROM, then that closes the hole – now the exception can only be raised at the innermost stack frame. This shouldn't have any performance implications, because the opcode check happens inside the "slow path" after we've already determined that there's a pending signal or something similar for us to process; the vast majority of the time this isn't true and the new check doesn't run at all.
* bpo-30184: Add tests for invalid use of PyArg_ParseTupleAndKeywords. (#1316)Serhiy Storchaka2017-05-031-2/+2
|
* convert from long long to PyLong loselessly (#1106)Benjamin Peterson2017-04-131-1/+1
|
* fix an error message and a comment in _testcapimodule.c (GH-392)orenmn2017-03-021-2/+3
|
* bpo-29548: Fix some inefficient call API usage (GH-97)INADA Naoki2017-02-161-1/+1
|
* Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE whereverSerhiy Storchaka2017-01-231-2/+1
| | | | possible but Coccinelle couldn't find opportunity.
* Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE whereverSerhiy Storchaka2017-01-231-24/+12
| | | | possible. Patch is writen with Coccinelle.
* Issue #28822: Adjust indices handling of PyUnicode_FindChar().Xiang Zhang2016-12-201-0/+22
|
* Merge 3.6Victor Stinner2016-12-151-0/+14
|\
| * Fix a memory leak in split-table dictionariesVictor Stinner2016-12-151-0/+14
| | | | | | | | | | | | | | Issue #28147: Fix a memory leak in split-table dictionaries: setattr() must not convert combined table into split table. Patch written by INADA Naoki.
* | Use _PyObject_CallNoArg()Victor Stinner2016-12-061-1/+1
| | | | | | | | | | | | | | Replace: PyObject_CallObject(callable, NULL) with: _PyObject_CallNoArg(callable)
* | Issue #19569: Compiler warnings are now emitted if use most of deprecatedSerhiy Storchaka2016-11-201-8/+4
| | | | | | | | functions.
* | Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka2016-11-161-1/+1
|\ \ | |/ | | | | | | | | _PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
| * Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka2016-11-161-1/+1
| |\ | | | | | | | | | | | | | | | _PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
| | * Issue #28701: Replace PyUnicode_CompareWithASCIIString with ↵Serhiy Storchaka2016-11-161-1/+1
| | | | | | | | | | | | | | | | | | _PyUnicode_EqualToASCIIString. The latter function is more readable, faster and doesn't raise exceptions.
* | | Issue #28123: _PyDict_GetItem_KnownHash() now can raise an exception asSerhiy Storchaka2016-11-061-0/+21
|\ \ \ | |/ / | | | | | | PyDict_GetItemWithError(). Patch by Xiang Zhang.
| * | Issue #28123: _PyDict_GetItem_KnownHash() now can raise an exception asSerhiy Storchaka2016-11-061-0/+21
| | | | | | | | | | | | PyDict_GetItemWithError(). Patch by Xiang Zhang.
* | | Issue #28379: Removed redundant check.Serhiy Storchaka2016-10-091-4/+0
|/ / | | | | | | Patch by Xiang Zhang.
* | Merge from 3.5.Serhiy Storchaka2016-10-081-0/+34
|\ \ | |/
| * Issue #28379: Added sanity checks and tests for PyUnicode_CopyCharacters().Serhiy Storchaka2016-10-081-0/+34
| | | | | | | | Patch by Xiang Zhang.
* | Issue #28295: Fixed the documentation and added tests for PyUnicode_AsUCS4().Serhiy Storchaka2016-10-021-0/+31
|\ \ | |/ | | | | Original patch by Xiang Zhang.