code: def detect_python2(source, pathname):
      
      RTs.setup_detect_python2()
      try:
          tree = RTs._rt_py2_detect.refactor_string(source, pathname)
      except ParseError as e:
          if e.msg != 'bad input' or e.value != '=':
              raise
          tree = RTs._rtp.refactor_string(source, pathname)
  
      if source != str(tree)[:-1]:   # remove added newline
          # The above fixers made changes, so we conclude it's Python 2 code
          logger.debug('Detected Python 2 code: {0}'.format(pathname))
          with open('/tmp/original_code.py', 'w') as f:
              f.write('### Original code (detected as py2): %s\n%s' %
                      (pathname, source))
          with open('/tmp/py2_detection_code.py', 'w') as f:
              f.write('### Code after running py3 detection (from %s)\n%s' %
                      (pathname, str(tree)[:-1]))
          return True
      else:
          logger.debug('Detected Python 3 code: {0}'.format(pathname))
          with open('/tmp/original_code.py', 'w') as f:
              f.write('### Original code (detected as py3): %s\n%s' %
                      (pathname, source))
          try:
              os.remove('/tmp/futurize_code.py')
          except OSError:
              pass
          return False
docs: Returns a bool indicating whether we think the code is Py2