Implicit conversion in dictionary, Jython bug?

So I have a Chart Range Selector on a view and I’m writing a binding on the data property such that I get an array of objects.

data = [{time:1,633,560,052,327, speed:148.1},etc...]

My first attempt looked like this:

    #add a time column into the pen names list
    names = ['time'] + names
	results = []
	for r in range(queryResults.rowCount):
		result= {}
		for c,name in enumerate(names):
			result[name] = queryResults.getValueAt(r,c) if name is not 'time' else system.date.toMillis(queryResults.getValueAt(r,c))
		results.append(result)
	return results

I thought this would work, however, the time was always converted back into a date.

My second attempt, doesn’t have this issue.

    #the 'time' key was not added into the names list.
	results = []
	for r in range(queryResults.rowCount):
		result= {'time':system.date.toMillis(queryResults.getValueAt(r,0))}
		for c,name in enumerate(names):
			result[name] = queryResults.getValueAt(r,c + 1)
		results.append(result)
	return results

My question is, why it is converted to a date in the first example, but not in the second one? Is this some kind of jython bug? system.date.toMillis() obviously returns and integer.

Also, in case it’s mentioned it doesn’t matter if the inline if statement is broken to a traditional if statement or not.

Any insight would be appriciated.

This is happening in a transform?

It might be the property editor trying to be ‘smart’ and assume that a long is actually a date and thus transforming it. The underlying property value should be left alone, it’s just displayed as a date in the property editor.

Yes, it is happening in a transform.

The first way, the property editor argues with me.

It list two errors for each item and the data property

  • data[0] array found object, array expected
  • data[0].time object found, string, number expected

The second way, everything is happy. What I don’t understand is why the long gets treated differently in the second case.

Hmm, is there any difference in the data types between the two scenarios? E.g. if you system.perspective.print(type(result["time"])) just before appending.

Output for the first example: java.sql.Timestamp
Output for the second example: org.python.core.PyLong

Well, I confess that I don’t see why, but that’s clearly the difference.