sgzwiz / brython

Automatically exported from code.google.com/p/brython
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Cthulhu (undefined) data type #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Save value returned by eval("") to the variable and try to do something with it.

What is the expected output? What do you see instead?
None, or something python can handle.

Here is output from my test console. > Exception < is just raised exception, 
not returned string:

>>> o = eval("")
>>> o
>>> print(o)
> Exception <
>>> print(str(o))

>>> print(">" + str(o) + "<")
><
>>> str(o) == ""
False
>>> len(str(o))
11
>>> isinstance(o, str)
False
>>> isinstance(o, int)
False
>>> isinstance(o, bool)
False
>>> isinstance(o, Object)
False
>>> isinstance(o, float)
False
>>> isinstance(o, list)
False
>>> isinstance(o, tuple)
False
>>> isinstance(o, dict)
False
>>> o == None
> Exception <
>>> dir(o)
[]
>>> dir(o) == []
True
>>> str(o)[1]
u
>>> for i in range(len(str(o))):
    print(str(o)[i])
<
u
n
d
e
f
i
n
e
d
>

What version of the product are you using? On what operating system?
1.0.20130116-074618

Please provide any additional information below.
It would be great if brython handled javascripts undefine data type smarter. 

Current version is uncomparable, unprintable data type, which converted to 
string is blank, but len() returns 11 and string is indexable, but unprintable.

Only way how to react to this data type i can imagine is compare result from 
dir().

Original issue reported on code.google.com by bystrousak@kitakitsune.org on 17 Jan 2013 at 10:36

GoogleCodeExporter commented 9 years ago

Original comment by pierre.q...@gmail.com on 26 Jan 2013 at 6:24

GoogleCodeExporter commented 9 years ago
Fixed in revision 441 : eval("") raises "SyntaxError: unexpected EOF while 
parsing" as in the CPython interpreter

Original comment by pierre.q...@gmail.com on 26 Jan 2013 at 7:33