Python 2.4 does not have the quote command in urllib2

Review Request #550 — Created Sept. 17, 2008 and submitted

Information

Review Board SVN (deprecated)
653

Reviewers

I got a traceback when viewing a patch submited from a Mercurial repository on my debian etch machine.

This patch solve this issue.
Works home.
chipx86
  1. 
      
  2. trunk/reviewboard/scmtools/hg.py (Diff revision 2)
     
     
     
    How I'd rather see this done is to try to import quote from urllib2 and, if there's an ImportError, import it from urllib.
  3. 
      
BE
  1. Version two.
  2. trunk/reviewboard/scmtools/hg.py (Diff revision 3)
     
     
    There might be a better way to check the availability of the command.
  3. trunk/reviewboard/scmtools/hg.py (Diff revision 3)
     
     
    This might be seen as dirty ... but has the advantage of solving it everywhere in one line.
  4. 
      
chipx86
  1. The way I'd advise is:
    
    try:
        from urllib2 import quote
    except ImportError:
        from urllib import quote
    1. But then you need to use "quote" instead of "urllib2.quote" everywhere, and you risk a name collision if something else is called quote.
      
      Anyway, If you're happy with you version, feel free to push ...
  2. 
      
david
  1. Committed a modified version as r1521. Thanks!
  2.