title: pickle.dump meet RuntimeError: maximum recursion depth exceeded in cmp
body: <p>I have noticed that it may be caused by beautifulsoup or recursive data structure. however, the data structure that cause error seems no problem:</p>
  
  <pre><code>class Movie:
  def __init__(self, name="", dscore=0, mscore=0, durl="", murl=""): 
      self.name = name
      self.dscore = float(dscore)
      self.mscore = float(mscore)
      self.durl = durl
      self.murl = murl
  def __str__(self):
      return unicode(self.name) + u' / ' + unicode(self.dscore) + u' / ' + unicode(self.mscore) \
          + u' / ' + unicode(self.durl) + u' / ' + unicode(self.murl)
  </code></pre>
  
  <p>The statement causing the problem is:</p>
  
  <pre><code>DataDict['MovieInfo'] = MovieInfo
  </code></pre>
  
  <p>and </p>
  
  <pre><code>pickle.dump(DataDict, f, True)
  </code></pre>
  
  <p>following is the function:</p>
  
  <pre><code>def SaveData():
  global LinkUrlQueue
  global MovieSet
  global MovieInfo
  global LinkUrlSet
  global MovieUrlQueue
  DataDict = {}
  DataDict['LinkUrlSet'] = LinkUrlSet
  DataDict['MovieSet'] = MovieSet
  #DataDict['MovieInfo'] = MovieInfo
  DataDict['LinkUrlQueue'] = LinkUrlQueue
  DataDict['MovieUrlQueue'] = MovieUrlQueue
  f = open('MovieInfo.txt', 'wb')
  
  for item in MovieInfo:
      f.write(item.__str__().encode('utf8') + '\n'.encode('utf8'))
  f.close()
  try:
      print 'saving data...'
      f = open('spider.dat', 'wb')
      pickle.dump(DataDict, f, True)
      f.close()
  except IOError as e:
      print 'IOError, error no: %d' % e.no
      print 'saved to spider2.dat'
      pickle.dump(DataDict, open('spider2.dat', 'wb'))
      time.sleep(10)
  </code></pre>
  
  <p>my complete source code:</p>
  
  <p>spider.py: <a href="http://paste.ubuntu.com/7149731/" rel="nofollow">http://paste.ubuntu.com/7149731/</a></p>
  
  <p>fetch.py: <a href="http://paste.ubuntu.com/7149732/" rel="nofollow">http://paste.ubuntu.com/7149732/</a></p>
  
  <p>You can just download and run.</p>
  
  <p>Besides, welcome any coding style suggestions</p>