Fixed #21321

Fixed #21321 and added test case about file iteration.
`TypeError: 'str' does not support the buffer interface`
When iterating raw file wrapped by `File` obj in python3 has been fixed.
Thanks.