Fix compatibility with Python < 2.7

Review Request #6207 — Created Aug. 7, 2014 and submitted

Information

Review Board
release-1.7.x
e0cef2b...

Reviewers

My change for handling alternate casing in svn:keywords only worked with Python
2.7 (prior versions don't have a `flags` argument to `re.sub()`).

This change makes it so we compile the regex first using re.IGNORECASE, and
then call the substitution method on the regex object.

Testing done: Ran tests under python 2.6

Ran tests under python 2.6

reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/scmtools/svn.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/scmtools/svn.py
    
    
  2. 
      
david
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/scmtools/tests.py
        reviewboard/scmtools/svn.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/scmtools/tests.py
        reviewboard/scmtools/svn.py
    
    
  2. 
      
chipx86
  1. Instead of all this, you can just put (?i) at the very beginning of the regex string, and it'll activate the right flag.

    1. Actually, the best way is for the regex to just be compiled instead of recreated every time. Then, you can pass the flag there.

    2. Well, the actual contents of the regex change based on the contents of the keywords property, so I can't avoid recreating it (we only want to do the substitution if svn also does the substitution). That said, I can use compile and then .sub on the regex object.

  2. 
      
david
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/scmtools/tests.py
        reviewboard/scmtools/svn.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/scmtools/tests.py
        reviewboard/scmtools/svn.py
    
    
  2. 
      
chipx86
  1. 
      
  2. reviewboard/scmtools/svn.py (Diff revision 3)
     
     
     

    Worth compiling it on the class?

    1. Can't be done. See my reply to your previous comment.

    2. Oh oops, you're right. Ship it!

  3. 
      
chipx86
  1. Ship It!

  2. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-1.7.x (4d0672b)
Loading...