Error encountered upon saving resource file after an extracted variable containing a comment is moved to that resource file
Originally submitted to Google Code by takht... on 3 May 2014
Versions:
pybot: Robot Framework 2.8.4 (Python 2.7.5 on win32) RIDE: RIDE 1.3 running on Python 2.7.5 OS: Windows 7
Steps to reproduce:
- In RIDE, while defining a test case or a keyword, create a variable from a value using 'Extract Variable' option from context menu.
- In the 'Scalar Variable' dialog, enter value for all - Name, Value, and Comment. Click OK.
- In the left hand side explorer view of RIDE, drag the newly created variable to another resource file.
-
Save the resource file to which variable was moved (in step-3). Note that: There is an error in RIDE as below (also attached) -
ERROR
Error in serializing 'd:\data\robot\ride_project\test_properties.txt': 'Comment' object does not support indexing
OK
RIDE behaves erroneously until the variable (moved in step-3) is deleted from resource file; Also, the resource file can't be saved till this variable is removed.
Expected behavior:
Variable should get moved to resource file and resource file can be saved.
Actual behavior:
- Resource file can't be saved until the variable is deleted from it. Upon saving the file, above mentioned error message is encountered.
- It can be difficult to figure out where the problem lies based on the error message.
It seems that the bug can be triggered just by moving a variable with comment from one file to another
Related traceback
Traceback (most recent call last):
File "src/robotide/editor/texteditor.py", line 111, in _on_timer
self._open_tree_selection_in_editor()
File "src/robotide/editor/texteditor.py", line 135, in _open_tree_selection_in_editor
self.global_settings))
File "src/robotide/editor/texteditor.py", line 399, in open
self._editor.set_text(self._data.content)
File "src/robotide/editor/texteditor.py", line 246, in content
return self._txt_data(self._data.data)
File "src/robotide/editor/texteditor.py", line 251, in _txt_data
txt_separating_spaces=self._settings['txt number of spaces'])
File "src/robotide/lib/robot/parsing/model.py", line 112, in save
return DataFileWriter(**options).write(self)
File "src/robotide/lib/robot/writer/datafilewriter.py", line 41, in write
FileWriter(ctx).write(datafile)
File "src/robotide/lib/robot/writer/filewriters.py", line 55, in write
self._write_table(table, is_last=table is tables[-1])
File "src/robotide/lib/robot/writer/filewriters.py", line 59, in _write_table
self._write_rows(self._formatter.format_table(table))
File "src/robotide/lib/robot/writer/filewriters.py", line 67, in _write_rows
for row in rows:
File "src/robotide/lib/robot/writer/formatters.py", line 45, in <genexpr>
return (self._format_row(r, table) for r in rows)
File "src/robotide/lib/robot/writer/formatters.py", line 51, in _split_rows
for original in original_rows:
File "src/robotide/lib/robot/writer/dataextractor.py", line 50, in _rows_from_item
yield [''] * indent + child.as_list()
File "src/robotide/lib/robot/parsing/model.py", line 477, in as_list
return [self.name] + self.value + self.comment.as_list()
File "src/robotide/lib/robot/parsing/comments.py", line 54, in as_list
if self._not_commented():
File "src/robotide/lib/robot/parsing/comments.py", line 59, in _not_commented
return self._comment and self._comment[0] and self._comment[0][0] != '#'
TypeError: 'Comment' object does not support indexing
This issue is still observable on 1.7.4.1dev0, Windows10, wxPython 4.0.7post2 and Python 2.7.16.
I wonder if the original author (from 2014) still uses and is interested in RIDE ;) This is fixed in v2.0.8dev2.
Always a pleasure to fix a bug from 2014 :).