changeset: 102034:0d39bd9028e8 parent: 102032:1f376758837d parent: 102033:e028e86a5b73 user: Victor Stinner date: Tue Jun 14 16:33:17 2016 +0200 files: Misc/NEWS Python/random.c description: Merge 3.5 (os.urandom, issue #27278) diff -r 1f376758837d -r 0d39bd9028e8 Misc/NEWS --- a/Misc/NEWS Tue Jun 14 15:05:21 2016 +0200 +++ b/Misc/NEWS Tue Jun 14 16:33:17 2016 +0200 @@ -10,6 +10,10 @@ Library ------- +- Issue #27278: Fix os.urandom() implementation using getrandom() on Linux. + Truncate size to INT_MAX and loop until we collected enough random bytes, + instead of casting a directly Py_ssize_t to int. + - Issue #16864: sqlite3.Cursor.lastrowid now supports REPLACE statement. Initial patch by Alex LordThorsen. diff -r 1f376758837d -r 0d39bd9028e8 Python/random.c --- a/Python/random.c Tue Jun 14 15:05:21 2016 +0200 +++ b/Python/random.c Tue Jun 14 16:33:17 2016 +0200 @@ -146,7 +146,7 @@ to 1024 bytes */ n = Py_MIN(size, 1024); #else - n = size; + n = Py_MIN(size, INT_MAX); #endif errno = 0;