File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -111,11 +111,19 @@ def _parse_header(self):
111111 # parse file until "</Configuration>"
112112 header_size = None
113113 with open (self .filename , mode = "rb" ) as f :
114+ # see https://github.com/NeuralEnsemble/python-neo/issues/1757 for bug with while loop
115+ # instead we seek the end of the file so we know when we are at the end
116+ # then readline returns an empty string at EOF so we confirm empty string + EOF location
117+ f .seek (0 ,2 )
118+ end_of_file = f .tell ()
119+ f .seek (0 )
114120 while True :
115121 line = f .readline ()
116122 if b"</Configuration>" in line :
117123 header_size = f .tell ()
118124 break
125+ if line == "" and f .tell () == end_of_file :
126+ break
119127
120128 if header_size is None :
121129 ValueError ("SpikeGadgets: the xml header does not contain '</Configuration>'" )
You can’t perform that action at this time.
0 commit comments