mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Fix a bug introduced in r62627. see issue2760 and issue2632.
An assertion in readline() would fail as data was already in the internal buffer even though the socket was in unbuffered read mode. That case is now handled. More importantly, read() has been fixed to not over-recv() and leave newly recv()d data in the _fileobject buffer. The max() vs min() issue in read() is now gone. Neither was correct. On bounded reads, always ask recv() for the exact amount of data we still need. Candidate for backporting to release25-maint along with r62627.
This commit is contained in:
		
							parent
							
								
									98fd03637f
								
							
						
					
					
						commit
						24237ea8a1
					
				
					 2 changed files with 45 additions and 19 deletions
				
			
		|  | @ -789,6 +789,33 @@ def _testReadline(self): | |||
|         self.cli_file.write(MSG) | ||||
|         self.cli_file.flush() | ||||
| 
 | ||||
|     def testReadlineAfterRead(self): | ||||
|         a_baloo_is = self.serv_file.read(len("A baloo is")) | ||||
|         self.assertEqual("A baloo is", a_baloo_is) | ||||
|         _a_bear = self.serv_file.read(len(" a bear")) | ||||
|         self.assertEqual(" a bear", _a_bear) | ||||
|         line = self.serv_file.readline() | ||||
|         self.assertEqual("\n", line) | ||||
|         line = self.serv_file.readline() | ||||
|         self.assertEqual("A BALOO IS A BEAR.\n", line) | ||||
|         line = self.serv_file.readline() | ||||
|         self.assertEqual(MSG, line) | ||||
| 
 | ||||
|     def _testReadlineAfterRead(self): | ||||
|         self.cli_file.write("A baloo is a bear\n") | ||||
|         self.cli_file.write("A BALOO IS A BEAR.\n") | ||||
|         self.cli_file.write(MSG) | ||||
|         self.cli_file.flush() | ||||
| 
 | ||||
|     def testReadlineAfterReadNoNewline(self): | ||||
|         end_of_ = self.serv_file.read(len("End Of ")) | ||||
|         self.assertEqual("End Of ", end_of_) | ||||
|         line = self.serv_file.readline() | ||||
|         self.assertEqual("Line", line) | ||||
| 
 | ||||
|     def _testReadlineAfterReadNoNewline(self): | ||||
|         self.cli_file.write("End Of Line") | ||||
| 
 | ||||
|     def testClosedAttr(self): | ||||
|         self.assert_(not self.serv_file.closed) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Gregory P. Smith
						Gregory P. Smith