Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TraitError when setting the 'singles' trait of a Player instance to string in examples/demo/Advanced/Tabular_editor_with_context_menu_demo.py when changing player to a string #2012

Closed
homosapien-lcy opened this issue Apr 25, 2023 · 4 comments

Comments

@homosapien-lcy
Copy link
Contributor

homosapien-lcy commented Apr 25, 2023

We have decided to close this issue without change due to the following reason:
After I run some other code, I found that the ui has changed and this bug no longer appears. I guess there might be some cached state saving somewhere that has been changed after I run some other code. So we decided to close this issue for now and investigate it further if reappears.


Problem:
When running examples/demo/Advanced/Tabular_editor_with_context_menu_demo.py, a trait error
traits.trait_errors.TraitError: The 'singles' trait of a Player instance must be an integer, but a value of 'sd' <class 'str'> was specified. It will be raised if editing the table to change any values under 'AB', 'SO', etc. to string

Replication Steps:

python examples/demo/Advanced/Tabular_editor_with_context_menu_demo.py

Then editting the table to change any values under 'AB', 'SO', etc. to string.

Expected Behavior:
Althought the change is an invalid change since it changes the data type that entries supposed to be, but should it caused the program to crash directly? (Not sure, is this supposed to be or a bug)

Environment:
[MacOS, python3.11]

Package:
Package Version Editable project location


apptools 5.2.0
attrdict 2.0.1
attrdict3 2.0.2
blosc2 2.0.0
celiagg 2.1.3
certifi 2022.12.7
chaco 5.1.0 /Users/cyliu/Documents/3.11_test/chaco
charset-normalizer 3.1.0
configobj 5.0.8
cPython 0.0.6
Cython 0.29.34
dnspython 2.3.0
enable 5.4.0.dev45 /Users/cyliu/Documents/3.11_test/enable
fonttools 4.39.2
h5py 3.8.0
idna 3.4
joblib 1.2.0
msgpack 1.0.5
numexpr 2.8.4
numpy 1.24.2
packaging 23.1
pandas 1.5.3
Pillow 9.4.0
pip 23.1
py-cpuinfo 9.0.0
PyAudio 0.2.13
pyface 8.0.0
pygarrayimage 1.0
pyglet 2.0.5 /Users/cyliu/Documents/3.11_test/pyglet
Pygments 2.14.0
pymongo 4.3.3
pyparsing 3.0.9
PySide6 6.4.3
PySide6-Addons 6.4.3
PySide6-Essentials 6.4.3
python-dateutil 2.8.2
pythonw 3.0.3
pytz 2023.2
reportlab 3.6.12
requests 2.28.2
scikit-learn 1.2.2
scipy 1.10.1
setuptools 65.6.3
shiboken6 6.4.3
six 1.16.0
tables 3.8.0
threadpoolctl 3.1.0
traits 7.0.0.dev1854 /Users/cyliu/Documents/3.11_test/traits
traitsui 8.0.0.dev0 /Users/cyliu/Documents/3.11_test/traitsui
urllib3 1.26.15
wxPython 4.2.0

@dpinte
Copy link
Member

dpinte commented Apr 25, 2023

For convenience, the link to the demo is available here: https://github.com/enthought/traitsui/blob/main/traitsui/examples/demo/Advanced/Tabular_editor_with_context_menu_demo.py

@homosapien-lcy did you check what the demo is supposed to do? Editing the table to change the integer values to a string is raising the appropriate error. For reference, https://github.com/enthought/traitsui/blob/main/traitsui/examples/demo/Advanced/Tabular_editor_with_context_menu_demo.py#L23

Based on that, is the error expected or not?

@dpinte dpinte changed the title traits.trait_errors.TraitError: The 'singles' trait of a Player instance must be an integer, but a value of 'sd' <class 'str'> was specified. happens in examples/demo/Advanced/Tabular_editor_with_context_menu_demo.py when changing player to a string TraitError when setting the 'singles' trait of a Player instance to string in examples/demo/Advanced/Tabular_editor_with_context_menu_demo.py when changing player to a string Apr 25, 2023
@dpinte
Copy link
Member

dpinte commented Apr 25, 2023

FYI in Python 3.8 setting the value of one of those items to a str value causes a segmentation fault.

@homosapien-lcy
Copy link
Contributor Author

homosapien-lcy commented Apr 26, 2023

https://github.com/enthought/traitsui/blob/main/traitsui/examples/demo/Advanced/Tabular_editor_with_context_menu_demo.py#L23

Yes, I know that this is supposed to be an illegal operation, but should it cause the program to crash directly? I was wondering about that because in another demo for instance, traitsui/examples/demo/Advanced/Popup_Dialog_demo.py, if the age is set to a string, the program will not crash directly but show the age entry as red to indicate its not correct (It also came to me that during our discussion of the usage of systemExit for traits library enthought/traits#1740, you and Mark mentioned the downstream user should not experience unexpected crashes):

Screen Shot 2023-04-26 at 9 46 37 AM

If you think the crash is supposed to be, we can close this issue

@homosapien-lcy
Copy link
Contributor Author

hmmm... I suddenly cannot replicate this anymore. After I run some other code, I found that the ui of this demo is completely changed, this it how it looks like right now:

Screen Shot 2023-04-28 at 3 33 15 PM

When I click on an entry in the table, it will only allow me to choose between "Add" and "Sub", and I'm not allowed to edit each entry myself which is how this demo supposed to do according to the documentation. But previously, the UI has no background and I can change the value in the table cells to generate this error.

I have tried restarting my computer, change the directory I ran from, re-download and setup the package, restarting my computer, but I didn't run into the interface I saw previously again... I guess there might be some cached state saving somewhere that has been changed after I run some other code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants