Following code works in Python2 but not in Python3?
import http.client
from io import StringIO
if __name__ == '__main__':
res=http.client.HTTPMessage(StringIO(u"headers"))
print(str(res))
[]$ python3 test.py
Traceback (most recent call last):
File "test.py", line 9, in <module>
print(str(res))
File "/usr/lib64/python3.9/email/message.py", line 135, in __str__
return self.as_string()
File "/usr/lib64/python3.9/email/message.py", line 158, in as_string
g.flatten(self, unixfrom=unixfrom)
File "/usr/lib64/python3.9/email/generator.py", line 97, in flatten
policy = policy.clone(max_line_length=self.maxheaderlen)
AttributeError: '_io.StringIO' object has no attribute 'clone'
I'm currently porting old Python2 code over to Python3. This is a dummy test of a problem I run into.