title: StringIO class does not return expected results in python 3
body: <p>This code that works in python version 2 fails in python 3. </p>
  
  <pre><code>AttributeError: '_io.StringIO' object has no attribute 'name'
  </code></pre>
  
  <p>Here is the code:</p>
  
  <blockquote>
    <p>!pip install
    warc3-wet</p>
  </blockquote>
  
  <pre><code>import warc
  import requests
  from contextlib import closing
  from io import StringIO
  
  def get_partial_warc_file(url, num_bytes=1024 * 10):
      with closing(requests.get(url, stream=True)) as r:
          buf = StringIO(r.raw.read(num_bytes).decode('utf-8'))  
      return warc.WARCFile(fileobj=buf, compress=True)
  
  urls = {
      'warc': 'https://aws-publicdatasets.s3.amazonaws.com/common-crawl/crawl-data/CC-MAIN-2016-07/segments/1454701145519.33/warc/CC-MAIN-20160205193905-00000-ip-10-236-182-209.ec2.internal.warc.gz',
      'wat':  'https://aws-publicdatasets.s3.amazonaws.com/common-crawl/crawl-data/CC-MAIN-2016-07/segments/1454701145519.33/wat/CC-MAIN-20160205193905-00000-ip-10-236-182-209.ec2.internal.warc.wat.gz',
      'wet':  'https://aws-publicdatasets.s3.amazonaws.com/common-crawl/crawl-data/CC-MAIN-2016-07/segments/1454701145519.33/wet/CC-MAIN-20160205193905-00000-ip-10-236-182-209.ec2.internal.warc.wet.gz'
  }
  
  files = {file_type: get_partial_warc_file(url=url) for file_type, url in urls.items()}
  </code></pre>
  
  <p>And here is source:</p>
  
  <p><a href="https://dmorgan.info/posts/common-crawl-python/" rel="nofollow noreferrer">https://dmorgan.info/posts/common-crawl-python/</a></p>
  
  <hr>
  
  <p>Update:</p>
  
  <p>This code returns the meta-data of the record, how do I read the news article?</p>
  
  <blockquote>
    <p>aws s3 cp --no-sign-request
    s3://commoncrawl/crawl-data/CC-NEWS/crawl-data/CC-NEWS/2019/08/CC-NEWS-20190824001636-00982.warc.gz</p>
  </blockquote>
  
  <pre><code>import warc
  
  var = 0 
  
  with warc.open("/tmp/CC-NEWS-20190824001636-00982.warc") as f:
      for record in f:
          if var &gt; 1:
              break
          else:
              print (record.date, record.from_response, record.header, record.ip_address, record.offset, record.payload, record.type, record.url, record.write_to)
          var = var + 1
  </code></pre>