title: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: get error: AttributeError: __exit__
body: <p>I have a socket server program:</p>
  
  <pre><code>#!/usr/bin/env python
  #-*- coding:utf-8 -*-
  # Author:sele
  
  
  import socket
  
  HOST = '127.0.0.1'
  PORT = 65432
  
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
      s.bind((HOST, PORT))
      s.listen()
      conn, addr = s.accept()
      with conn:
          print('Connected by', addr)
          while True:
              data = conn.recv(1024)
              if not data:
                  break
  
              conn.sendall(data)
  </code></pre>
  
  <p>when I run it in my terminal:</p>
  
  <p>there get error:</p>
  
  <blockquote>
    <p>sele-MacBook-Pro:test01 ldl$ ./tests02-server.py<br>
        Traceback (most recent call last):<br>
          File "./tests02-server.py", line 11, in <br>
            with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:<br>
        AttributeError: <strong>exit</strong>  </p>
  </blockquote>
  
  <p>why there get this error?</p>