summaryrefslogtreecommitdiffstats
path: root/Modules/_randommodule.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-40286: Makes simpler the relation between randbytes() and getrandbits() ↵Serhiy Storchaka2020-04-171-12/+6
| | | | (GH-19574)
* bpo-40282: Allow random.getrandbits(0) (GH-19539)Antoine Pitrou2020-04-171-2/+5
|
* bpo-40302: Replace PY_INT64_T with int64_t (GH-19573)Victor Stinner2020-04-171-6/+6
| | | | | | | | | * Replace PY_INT64_T with int64_t * Replace PY_UINT32_T with uint32_t * Replace PY_UINT64_T with uint64_t sha3module.c no longer checks if PY_UINT64_T is defined since it's always defined and uint64_t is always available on platforms supported by Python.
* bpo-40286: Add randbytes() method to random.Random (GH-19527)Victor Stinner2020-04-171-7/+58
| | | | | | | | | | | | Add random.randbytes() function and random.Random.randbytes() method to generate random bytes. Modify secrets.token_bytes() to use SystemRandom.randbytes() rather than calling directly os.urandom(). Rename also genrand_int32() to genrand_uint32(), since it returns an unsigned 32-bit integer, not a signed integer. The _random module is now built with Py_BUILD_CORE_MODULE defined.
* bpo-39968: Convert extension modules' macros of get_module_state() to inline ↵Hai Shi2020-03-161-7/+13
| | | | functions (GH-19017)
* bpo-38075: Fix random_seed(): use PyObject_CallOneArg() (GH-18897)Victor Stinner2020-03-101-4/+1
| | | | | | Fix the random.Random.seed() method when a bool is passed as the seed. PyObject_Vectorcall() was misused: use PyObject_CallOneArg() instead.
* bpo-39245: Switch to public API for Vectorcall (GH-18460)Petr Viktorin2020-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The bulk of this patch was generated automatically with: for name in \ PyObject_Vectorcall \ Py_TPFLAGS_HAVE_VECTORCALL \ PyObject_VectorcallMethod \ PyVectorcall_Function \ PyObject_CallOneArg \ PyObject_CallMethodNoArgs \ PyObject_CallMethodOneArg \ ; do echo $name git grep -lwz _$name | xargs -0 sed -i "s/\b_$name\b/$name/g" done old=_PyObject_FastCallDict new=PyObject_VectorcallDict git grep -lwz $old | xargs -0 sed -i "s/\b$old\b/$new/g" and then cleaned up: - Revert changes to in docs & news - Revert changes to backcompat defines in headers - Nudge misaligned comments
* bpo-38321: Fix compiler warning in _randommodule.c (GH-16512)Victor Stinner2019-10-011-1/+1
| | | | Fix the GCC warning: "initialization discards ‘const’ qualifier from pointer target type".
* Fix missing dec ref (#16158)Dino Viehland2019-09-151-0/+1
|
* bpo-38075: Port _randommodule.c to PEP-384 (GH-15798)Dino Viehland2019-09-131-57/+92
| | | | | | | | | | - Migrate `Random_Type` to `PyType_FromSpec` - To simulate an old use of `PyLong_Type.tp_as_number->nb_absolute`, I added code to the module init function to stash `int.__abs__` for later use. Ideally we'd use `PyType_GetSlot()` instead, but it doesn't currently work for static types in CPython, and implementing it just for this case doesn't seem worth it. - Do exact check for long and dispatch to PyNumber_Absolute, use vector call when not exact.
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-2/+2
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo-37021: Port _randommodule to the argument clinic (GH-13532)Pablo Galindo2019-05-241-26/+83
|
* closes bpo-35991: Fix a potential double free in Modules/_randommodule.c. ↵Zackery Spytz2019-02-141-1/+0
| | | | (GH-11849)
* bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. ↵Siddhesh Poyarekar2018-04-291-2/+2
| | | | | | | | | (GH-6030) METH_NOARGS functions need only a single argument but they are cast into a PyCFunction, which takes two arguments. This triggers an invalid function cast warning in gcc8 due to the argument mismatch. Fix this by adding a dummy unused argument.
* bpo-31478: Fix an assertion failure in random.seed() in case a seed has a ↵Oren Milman2017-09-281-2/+5
| | | | bad __abs__() method. (#3596)
* bpo-30592: Fixed error messages for some builtins. (#1996)Serhiy Storchaka2017-06-081-1/+1
| | | | | Error messages when pass keyword arguments to some builtins that don't support keyword arguments contained double parenthesis: "()()". The regression was introduced by bpo-30534.
* bpo-29960 _random.Random corrupted on exception in setstate(). (#1019)bladebryan2017-04-221-1/+4
|
* Update URL of Mersenne Twister Home Page (#20)Hiroki Noda2017-02-151-3/+3
|
* Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE whereverSerhiy Storchaka2017-01-231-2/+1
| | | | possible. Patch is writen with Coccinelle.
* fix error check, so that Random.seed actually uses OS randomness (closes #29085)Benjamin Peterson2016-12-291-1/+1
|
* Issue #27776: include process.h on Windows for getpid()Victor Stinner2016-09-071-0/+3
|
* os.urandom() now blocks on LinuxVictor Stinner2016-09-061-10/+46
| | | | | | | Issue #27776: The os.urandom() function does now block on Linux 3.17 and newer until the system urandom entropy pool is initialized to increase the security. This change is part of the PEP 524.
* replace Python aliases for standard integer types with the standard integer ↵Benjamin Peterson2016-09-061-24/+20
| | | | types (#17884)
* Fix typos. Reported by andportnoy on GitHub.Berker Peksag2016-04-291-1/+1
|
* Issue #25923: Added the const qualifier to static constant arrays.Serhiy Storchaka2015-12-251-1/+1
|
* Issue #24620: Random.setstate() now validates the value of state last element.Serhiy Storchaka2015-07-241-0/+4
|\
| * Issue #24620: Random.setstate() now validates the value of state last element.Serhiy Storchaka2015-07-241-0/+4
| |
* | Issue #23488: Fix a syntax error on big endian platforms.Zachary Ware2015-05-181-1/+1
| | | | | | | | Hopefully this will allow the PPC64 PowerLinux buildbot to finish a test run.
* | Issue #23488: Random generator objects now consume 2x less memory on 64-bit.Serhiy Storchaka2015-05-131-70/+68
| |
* | Improve struct cache locality by bring commonly accessed fields close together.Raymond Hettinger2015-02-201-1/+1
|/
* Fix compiler warning on Windows 64-bit: explicit cast size_t to unsigned longVictor Stinner2013-11-151-2/+2
|
* Issue #18783: Removed existing mentions of Python long type in docstrings,Serhiy Storchaka2013-08-271-1/+1
|\ | | | | | | error messages and comments.
| * Issue #18783: Removed existing mentions of Python long type in docstrings,Serhiy Storchaka2013-08-271-1/+1
| | | | | | | | error messages and comments.
* | Issue #18408: random_seed() now raises a MemoryError on memory allocationVictor Stinner2013-07-151-1/+4
| | | | | | | | failure
* | Issue #16674: random.getrandbits() is now 20-40% faster for small integers.Serhiy Storchaka2013-01-041-0/+3
| |
* | Simplify random_seed to use _PyLong_AsByteArray. Closes issue #16496.Mark Dickinson2012-12-211-64/+35
|/
* Issue #16096: Fix several occurrences of potential signed integer overflow. ↵Mark Dickinson2012-10-061-1/+2
| | | | Thanks Serhiy Storchaka.
* Issue #14815: Bugfix: the PyLong fed into the seed generator must be unsigned.Larry Hastings2012-06-241-4/+5
|
* Issue #14815: Use Py_ssize_t instead of long for the object hash, toLarry Hastings2012-06-241-2/+2
| | | | preserve all 64 bits of hash on Win64.
* Issue #14909: A number of places were using PyMem_Realloc() apis andKristjan Valur Jonsson2012-05-311-3/+4
| | | | | PyObject_GC_Resize() with incorrect error handling. In case of errors, the original object would be leaked. This checkin fixes those cases.
* tabbing no longer applicableBenjamin Peterson2010-08-241-1/+1
|
* Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou2010-05-091-357/+357
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
* Merged revisions 72344 via svnmerge fromMark Dickinson2009-05-051-1/+1
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r72344 | mark.dickinson | 2009-05-05 18:41:47 +0100 (Tue, 05 May 2009) | 3 lines Issue #5933: Fix some gcc -Wextra warnings. Thanks Victor Stinner for the patch. ........
* Issue #1717: rename tp_compare to tp_reserved. I'll change theMark Dickinson2009-02-021-1/+1
| | | | | type of tp_compare in a separate commit, for ease of reversion should things go wrong.
* Implement PEP 3121: new module initialization and finalization API.Martin v. Löwis2008-06-111-4/+18
|
* Remove defunct parts of the random moduleRaymond Hettinger2008-01-131-69/+0
|
* #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.Christian Heimes2007-12-191-2/+2
|
* Merged revisions 59275-59303 via svnmerge fromChristian Heimes2007-12-031-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTE: The merge does NOT contain the modified file Python/import.c from r59288. I can't get it running. Nick, please check in the PEP 366 manually. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ........ r59279 | georg.brandl | 2007-12-02 19:17:50 +0100 (Sun, 02 Dec 2007) | 2 lines Fix a sentence I missed before. Do not merge to 3k. ........ r59281 | georg.brandl | 2007-12-02 22:58:54 +0100 (Sun, 02 Dec 2007) | 3 lines Add documentation for PySys_* functions. Written by Charlie Shepherd for GHOP. Also fixes #1245. ........ r59288 | nick.coghlan | 2007-12-03 13:55:17 +0100 (Mon, 03 Dec 2007) | 1 line Implement PEP 366 ........ r59290 | christian.heimes | 2007-12-03 14:47:29 +0100 (Mon, 03 Dec 2007) | 3 lines Applied my patch #1455 with some extra fixes for VS 2005 The new msvc9compiler module supports VS 2005 and VS 2008. I've also fixed build_ext to support PCbuild8 and PCbuild9 and backported my fix for xxmodule.c from py3k. The old code msvccompiler is still in place in case somebody likes to build an extension with VS 2003 or earlier. I've also updated the cygwin compiler module for VS 2005 and VS 2008. It works with VS 2005 but I'm unable to test it with VS 2008. We have to wait for a new version of cygwin. ........ r59291 | christian.heimes | 2007-12-03 14:55:16 +0100 (Mon, 03 Dec 2007) | 1 line Added comment to Misc/NEWS for r59290 ........ r59292 | christian.heimes | 2007-12-03 15:28:04 +0100 (Mon, 03 Dec 2007) | 1 line I followed MA Lemberg's suggestion and added comments to the late initialization of the type slots. ........ r59293 | facundo.batista | 2007-12-03 17:29:52 +0100 (Mon, 03 Dec 2007) | 3 lines Speedup and cleaning of __str__. Thanks Mark Dickinson. ........ r59294 | facundo.batista | 2007-12-03 18:55:00 +0100 (Mon, 03 Dec 2007) | 4 lines Faster _fix function, and some reordering for a more elegant coding. Thanks Mark Dickinson. ........ r59295 | martin.v.loewis | 2007-12-03 20:20:02 +0100 (Mon, 03 Dec 2007) | 5 lines Issue #1727780: Support loading pickles of random.Random objects created on 32-bit systems on 64-bit systems, and vice versa. As a consequence of the change, Random pickles created by Python 2.6 cannot be loaded in Python 2.5. ........ r59297 | facundo.batista | 2007-12-03 20:49:54 +0100 (Mon, 03 Dec 2007) | 3 lines Two small fixes. Issue 1547. ........ r59299 | georg.brandl | 2007-12-03 20:57:02 +0100 (Mon, 03 Dec 2007) | 2 lines #1548: fix apostroph placement. ........ r59300 | christian.heimes | 2007-12-03 21:01:02 +0100 (Mon, 03 Dec 2007) | 3 lines Patch #1537 from Chad Austin Change GeneratorExit's base class from Exception to BaseException (This time I'm applying the patch to the correct sandbox.) ........ r59302 | georg.brandl | 2007-12-03 21:03:46 +0100 (Mon, 03 Dec 2007) | 3 lines Add examples to the xmlrpclib docs. Written for GHOP by Josip Dzolonga. ........
* Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases ↵Christian Heimes2007-12-021-7/+7
| | | | in intobject.h
* Remove checking redundantly for checks of PyInt and PyLong.Neal Norwitz2007-08-311-2/+2
|