File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -411,16 +411,12 @@ def _reset(self, something):
411411 # BytesIO is significant, advise caller to pass a stream instead.
412412 self ._stream = io .BytesIO (something )
413413 elif isinstance (something , io .IOBase ):
414- # 'something' is a proper IO stream
414+ # 'something' is a proper IO stream - must be seekable for parsing
415415 if something .seekable ():
416- # Seekable stream, use directly
417416 self ._stream = something
418- elif something .readable ():
419- # Readable but not seekable, wrap in BufferedReader
420- self ._stream = io .BufferedReader (something )
421417 else :
422418 raise LLSDParseError (
423- "Cannot parse LLSD from non-readable stream."
419+ "Cannot parse LLSD from non-seekable stream."
424420 )
425421 else :
426422 # Invalid input type - raise a clear error
Original file line number Diff line number Diff line change @@ -2022,4 +2022,14 @@ def test_parse_int_raises_error(self):
20222022 llsd .parse (42 )
20232023 self .assertIn ('int' , str (context .exception ))
20242024
2025+ def test_parse_non_seekable_stream_raises_error (self ):
2026+ '''
2027+ Parsing a non-seekable stream should raise LLSDParseError.
2028+ '''
2029+ stream = io .BytesIO ()
2030+ stream .seekable = lambda : False
2031+ with self .assertRaises (llsd .LLSDParseError ) as context :
2032+ llsd .parse (stream )
2033+ self .assertIn ('non-seekable' , str (context .exception ))
2034+
20252035
You can’t perform that action at this time.
0 commit comments