0

We are migrating our python project code from py2.7 code to py3.7, as part of migration process code should be compatible with both py27 and py37 versions.

to become compatible with both the version we are using six library. Here I could see an unexpected behaviour of the six.StringIO to read Table object, its giving an error as below, but its fine with String.IO.StringIO module of py2.7, Please suggest the approach to make it run in both the versions without any error As per python doc: its alias, Can you help me to understand this behaviour. Thanks

Here is the example code of it, to read Table object in py2.7: My question here is why six.StringIO is not capable to generate instance like StringIO.StringIO class of py2.7

>> import StringIO
>> StringIO.StringIO(tableObj)
>> <StringIO.StringIO instance at 0x00000000000B2AFF>
>> from six import StringIO as StringIO 
>> StringIO.StringIO(tableObj)
 Traceback (most recent call last):
 File "<pyshell#20>", line 1, in <module> 
      StringIO.StringIO(tableObj)
 TypeError: StringIO() argument 1 must be convertible to a buffer, not Table
 >>
Rubia
  • 445
  • 2
  • 6
  • 17
  • Show us a copy-paste of an actual interpreter session demonstrating the problem. What you've shown looks like you just made up a bunch of fake output. – user2357112 Mar 10 '19 at 22:18
  • That's still clearly not the output of an actual interpreter session. What you're showing us couldn't possibly be what actually happened. You're skipping important details and trying to replicate results you don't understand by hand. We need to see a [mcve]. – user2357112 Mar 10 '19 at 22:35

0 Answers0