[issue3708] os.urandom(1.1): infinite loop

2008-09-18 Thread Roumen Petrov
Roumen Petrov <[EMAIL PROTECTED]> added the comment: It seems to me that test case will fail on windows and vms platforms. The case contain os.urandom(1.1) but in posixmodule.c for urandon functions (windows and vms) exits: PyArg_ParseTuple(args, "i:urandom", &howMany)) ./python.exe -c 'import

[issue3708] os.urandom(1.1): infinite loop

2008-09-08 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: Apparently this isn't an issue in py3k, so no worries! :) ___ Python tracker <[EMAIL PROTECTED]> ___ ___

[issue3708] os.urandom(1.1): infinite loop

2008-09-08 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: Gregory, could you merge this into py3k, please? -- nosy: +benjamin.peterson ___ Python tracker <[EMAIL PROTECTED]> ___ ___

[issue3708] os.urandom(1.1): infinite loop

2008-09-01 Thread Gregory P. Smith
Gregory P. Smith <[EMAIL PROTECTED]> added the comment: committed to trunk r66142 -- status: open -> closed ___ Python tracker <[EMAIL PROTECTED]> ___ _

[issue3708] os.urandom(1.1): infinite loop

2008-09-01 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: The patch looks fine to me as well. -- keywords: -needs review nosy: +amaury.forgeotdarc resolution: -> accepted ___ Python tracker <[EMAIL PROTECTED]> __

[issue3708] os.urandom(1.1): infinite loop

2008-08-28 Thread Antoine Pitrou
Antoine Pitrou <[EMAIL PROTECTED]> added the comment: Le jeudi 28 août 2008 à 19:30 +, Gregory P. Smith a écrit : > if i did > > n = int(n) > > that would change the API to allow bytes/unicode to be passed in which > is not something i want. Ok, I hadn't thought about that. You convinced

[issue3708] os.urandom(1.1): infinite loop

2008-08-28 Thread Daniel Diniz
Daniel Diniz <[EMAIL PROTECTED]> added the comment: Gregory, IMHO your patch is better in all aspects. Regarding my patch, the API wouldn't change at all, as the source reads: while len(bytes) < int(n): bytes += read(_urandomfd, n - len(bytes)) So "n - len(bytes)" restricts

[issue3708] os.urandom(1.1): infinite loop

2008-08-28 Thread Gregory P. Smith
Gregory P. Smith <[EMAIL PROTECTED]> added the comment: if i did n = int(n) that would change the API to allow bytes/unicode to be passed in which is not something i want. i don't even like that it allows floats. by not doing the int conversion at all, a DeprecationWarning is raised by the

[issue3708] os.urandom(1.1): infinite loop

2008-08-28 Thread Antoine Pitrou
Antoine Pitrou <[EMAIL PROTECTED]> added the comment: The explicit int() conversion looked saner to me, rather than passing a float argument to read(). By the way, is there a reason this code still uses os.open rather than the builtin io.open? -- nosy: +pitrou __

[issue3708] os.urandom(1.1): infinite loop

2008-08-27 Thread Gregory P. Smith
Gregory P. Smith <[EMAIL PROTECTED]> added the comment: better patch with tests attached, no explicit int conversion is done. i also wrapped the use of the fd returned by open with a try: finally: to avoid any chance of a leak and renamed the bytes variable to bs to match whats in py3k and avoid

[issue3708] os.urandom(1.1): infinite loop

2008-08-27 Thread Gregory P. Smith
Gregory P. Smith <[EMAIL PROTECTED]> added the comment: i'll fix this and add a unit test. -- assignee: -> gregory.p.smith keywords: +easy nosy: +gregory.p.smith priority: -> low ___ Python tracker <[EMAIL PROTECTED]>

[issue3708] os.urandom(1.1): infinite loop

2008-08-27 Thread Daniel Diniz
New submission from Daniel Diniz <[EMAIL PROTECTED]>: Calling os.urandom(1 + float(x)) ends in a infinite loop due to a naive condition check: while len(bytes) < n: bytes += read(_urandomfd, n - len(bytes)) Trivial patch attached. -- components: Library (Lib) files: urandom.diff ke