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

IndexError: index out of range in STDF.records_from_file #55

Open
Freeman266 opened this issue Nov 10, 2022 · 4 comments
Open

IndexError: index out of range in STDF.records_from_file #55

Freeman266 opened this issue Nov 10, 2022 · 4 comments

Comments

@Freeman266
Copy link

Tasks/Steps/Elements

Need your help on this index out of range. Below is the error

Traceback (most recent call last):

File "C:\Users\user\stdf\stdrreader.py", line 10, in
for REC in STDF.records_from_file("stdf.std"):

File "C:\Users\user\Anaconda3\lib\site-packages\semi_ate_stdf-0.0.0-py3.8.egg\Semi_ATE\STDF\utils.py", line 810, in next
return create_record_object(self.version, self.endian, (REC_TYP, REC_SUB), header+footer)

File "C:\Users\user\Anaconda3\lib\site-packages\semi_ate_stdf-0.0.0-py3.8.egg\Semi_ATE\STDF\utils.py", line 861, in create_record_object
retval = create_record(Version, Endian, REC_ID, REC)

File "C:\Users\user\Anaconda3\lib\site-packages\semi_ate_stdf-0.0.0-py3.8.egg\Semi_ATE\STDF\utils.py", line 885, in create_record
retval = GDR(Version, Endian, REC)

File "C:\Users\user\Anaconda3\lib\site-packages\semi_ate_stdf-0.0.0-py3.8.egg\Semi_ATE\STDF\GDR.py", line 35, in init
self._default_init(endian, record)

File "C:\Users\user\Anaconda3\lib\site-packages\semi_ate_stdf-0.0.0-py3.8.egg\Semi_ATE\STDF\STDR.py", line 265, in _default_init
self._unpack(record)

File "C:\Users\user\Anaconda3\lib\site-packages\semi_ate_stdf-0.0.0-py3.8.egg\Semi_ATE\STDF\STDR.py", line 1798, in _unpack
self._unpack_item(items[index])

File "C:\Users\user\Anaconda3\lib\site-packages\semi_ate_stdf-0.0.0-py3.8.egg\Semi_ATE\STDF\STDR.py", line 1508, in _unpack_item
code = self.buffer[0]

IndexError: index out of range

Versions checklist

  • Spyder version: >= 4.2.5
  • Python version: 3.8.8
  • Qt version: all
  • PyQt version: all
  • Operating System name/version:
    • client : Windows
@csraghu
Copy link

csraghu commented Jan 26, 2023

I ran into the same issue and looks like the problem is due to the buffer being empty. By just breaking out of the loop when the buffer is empty fixes the error. Probably that might not be the right solution (though it works). Will be glad if this issue can be resolved.

Thanks

@nanorpi
Copy link

nanorpi commented Aug 24, 2023

I ran into the same issue and looks like the problem is due to the buffer being empty. By just breaking out of the loop when the buffer is empty fixes the error. Probably that might not be the right solution (though it works). Will be glad if this issue can be resolved.

Thanks

Thanks for sharing, could you comment which line you modified and how to do that? I got error below which is similar but at different lines. Thanks!
IndexError Traceback (most recent call last)
in
17 i=0
18 started = datetime.now()
---> 19 for REC in STDF.records_from_file(stdf_path):
20 i=i+1
21 stdf_dict = REC.to_dict()

~\Anaconda3\lib\site-packages\Semi_ATE\STDF\utils.py in next(self)
808 raise StopIteration()
809 else:
--> 810 return create_record_object(self.version, self.endian, (REC_TYP, REC_SUB), header+footer)
811 # seimit: the old code, does not corresponds to the README file
812 # but it is used in STDFFile class

~\Anaconda3\lib\site-packages\Semi_ATE\STDF\utils.py in create_record_object(Version, Endian, REC_ID, REC)
859
860 if REC_TYP != -1 and REC_SUB != -1:
--> 861 retval = create_record(Version, Endian, REC_ID, REC)
862 return retval
863

~\Anaconda3\lib\site-packages\Semi_ATE\STDF\utils.py in create_record(Version, Endian, REC_ID, REC)
883 retval = FTR(Version, Endian, REC)
884 elif REC_ID == 'GDR':
--> 885 retval = GDR(Version, Endian, REC)
886 elif REC_ID == 'HBR':
887 retval = HBR(Version, Endian, REC)

~\Anaconda3\lib\site-packages\Semi_ATE\STDF\GDR.py in init(self, version, endian, record)
33 else:
34 raise STDR.STDFError("%s object creation error: unsupported version '%s'" % (self.id, version))
---> 35 self._default_init(endian, record)
36
37 def to_atdf(self):

~\Anaconda3\lib\site-packages\Semi_ATE\STDF\STDR.py in _default_init(self, endian, record)
263 if record != None:
264 if self.local_debug: print("len(%s) = %s" % (self.id, len(record)))
--> 265 self._unpack(record)
266
267 def call(self, endian = None, record = None):

~\Anaconda3\lib\site-packages\Semi_ATE\STDF\STDR.py in _unpack(self, record)
1796 items[self.fields[index]['#']]=index
1797 for index in range(len(items)):
-> 1798 self._unpack_item(items[index])
1799
1800 def Vn_decode(self, BUFF, endian):

~\Anaconda3\lib\site-packages\Semi_ATE\STDF\STDR.py in _unpack_item(self, FieldID)
1340 def _unpack_item(self, FieldID):
1341 if len(self.buffer) == 0:
-> 1342 self.set_value(FieldID, self.fields[FieldID]['Missing'])
1343 self.missing_fields += 1
1344 else:

~\Anaconda3\lib\site-packages\Semi_ATE\STDF\STDR.py in set_value(self, FieldID, Value)
523 self.fields[FieldKey]['Value'] = []
524
--> 525 code = temp[0][0]
526
527 if code < 0 or code == 9 or code > 13 :

IndexError: list index out of range

@dmitry5999
Copy link

Same issue happen to me as well. Looks like treating GDR record is buggy. Sometimes buffer parsing ends up to be empty.
I fixed it as described before. Only note yo should not break the loop, but continue. Writing GDR record back to STDF is buggy as well. Failing the check of record length.

@aulinof
Copy link

aulinof commented Apr 11, 2024

Hello to everyone, based on your strategy to solve the problem, maybe I have found a solution for which I don't know if necessary to submit it to any approval cycle. I have modified the code directly in the file STDR.py in the library. In particular I have added in the old one row 1508 the code "if self.buffer[0] else 'empty'" and also added the new two rows 1509 e 1510. Bye Thanks

1507 for i in range(K):
1508 code = self.buffer[0] if self.buffer[0] else 'empty'
1509 if code == 'empty':
1510 break
1511 if code == 0:

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

5 participants