All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bugtests.test380.py Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

The newest version!
"""
fixed broken id checks with pickle and copy that depends on id working correctly
"""

import support

d = {}

import java

clash_id = java.lang.System.identityHashCode

for i in xrange(100000):
  s = ['test',i]
  j = clash_id(s)
  if d.has_key(j):
    break
  d[j] = s

s1 = s
s0 = d[j]

data = [s0,s1,s0]

#print data

import pickle
import cPickle

def check(ctxt,data0,data1):
    if data0 != data1:
        raise support.TestError,"data corrupted in %s because of id clashes: %s != %s" % (ctxt.__name__,data0,data1)

def pik_test(pikmod,data):
    pik =pikmod.dumps(data,1)
    data1 = pikmod.loads(pik)
    check(pikmod,data,data1)

pik_test(cPickle,data)
pik_test(pickle,data)

import copy

check(copy.deepcopy,data,copy.deepcopy(data))




© 2015 - 2025 Weber Informatics LLC | Privacy Policy