Issue1167

classification
Title: random.py in standard library is broken in 2.5beta0
Type: behaviour Severity: normal
Components: Core Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: marcdownie, pjenvey
Priority: Keywords:

Created on 2008-11-09.01:39:07 by marcdownie, last changed 2008-11-23.03:16:38 by pjenvey.

Files
File name Uploaded Description Edit Remove
unnamed marcdownie, 2008-11-23.02:39:03
Messages
msg3764 (view) Author: Marc Downie (marcdownie) Date: 2008-11-09.01:39:06
Importing random fails with the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File 
"/Users/marc/fieldwork/field/distribution/application/field.app/Contents
/Resources/Java/../../../../../../development/depends/jython2.5b0/Lib/ra
ndom.py", line 838, in <module>
    _inst = Random()
  File 
"/Users/marc/fieldwork/field/distribution/application/field.app/Contents
/Resources/Java/../../../../../../development/depends/jython2.5b0/Lib/ra
ndom.py", line 94, in __init__
    self.seed(x)
  File 
"/Users/marc/fieldwork/field/distribution/application/field.app/Contents
/Resources/Java/../../../../../../development/depends/jython2.5b0/Lib/ra
ndom.py", line 113, in seed
    super(Random, self).seed(a)
OverflowError: long too big to convert

"Fixing" the line:

super(Random, self).seed(a)

to be:

super(Random, self).seed(1)

gets a new error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File 
"/Users/marc/fieldwork/field/distribution/application/field.app/Contents
/Resources/Java/../../../../../../development/depends/jython2.5b0/Lib/ra
ndom.py", line 861, in <module>
    getrandbits = _inst.getrandbits
AttributeError: 'Random' object has no attribute 'getrandbits'

commenting out the offending assignment gets you an importing random 
package.

Perhaps the symptom of a core bug rather than a library one? I also 
recall using random in 2.5alpha3.
msg3766 (view) Author: Marc Downie (marcdownie) Date: 2008-11-09.04:08:48
This might be related to issue 1166 (which also has a related long 
conversion error that's marked against 2.5beta0).

To answer the questions posed there --- this is not a 64bit JVM (it's a 
32bit Java 1.5 on Mac OS X, build 1.5.0_16-b06-284) and os._native_posix 
is true.
msg3816 (view) Author: Philip Jenvey (pjenvey) Date: 2008-11-23.02:31:09
Is this always reproducible or is it a flakey thing?

Oddly enough I couldn't reproduce it with a number of tries on OS X 32 bit 
Java 1.5.0_16-b06-284 (same as yours) -- on the i386 platform
msg3817 (view) Author: Marc Downie (marcdownie) Date: 2008-11-23.02:39:03
Hmm. It's always reproducible here. However: I am running Jython embedded
inside my own application.
And (just checked), from inside the jython command line wrapper, "import
random" works just fine.

Yikes. The application is open source (http://openendedgroup.com/field) but
it's going to put everybody a long way from any bug inside Jython. I'll
start taking a closer look and report back.
msg3819 (view) Author: Marc Downie (marcdownie) Date: 2008-11-23.03:11:52
Close this. 

My apologies: thought my application was using 2.5beta0, when it was 
actually still using 2.5alpha3.
msg3820 (view) Author: Philip Jenvey (pjenvey) Date: 2008-11-23.03:16:38
No worries, thanks for looking back into this
History
Date User Action Args
2008-11-23 03:16:38pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg3820
2008-11-23 03:11:52marcdowniesetmessages: + msg3819
2008-11-23 02:39:03marcdowniesetfiles: + unnamed
messages: + msg3817
2008-11-23 02:31:09pjenveysetnosy: + pjenvey
messages: + msg3816
2008-11-09 04:08:49marcdowniesetmessages: + msg3766
2008-11-09 01:39:07marcdowniecreate