[Python-checkins] python/dist/src/Lib/distutils util.py,1.74,1.75

loewis at users.sourceforge.net loewis at users.sourceforge.net
Thu Mar 25 09:58:25 EST 2004


Update of /cvsroot/python/python/dist/src/Lib/distutils
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18673

Modified Files:
	util.py 
Log Message:
Defer compilation of regular expressions until first use.


Index: util.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/util.py,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -d -r1.74 -r1.75
*** util.py	12 Feb 2004 17:35:08 -0000	1.74
--- util.py	25 Mar 2004 14:58:19 -0000	1.75
***************
*** 210,216 ****
  
  # Needed by 'split_quoted()'
! _wordchars_re = re.compile(r'[^\\\'\"%s ]*' % string.whitespace)
! _squote_re = re.compile(r"'(?:[^'\\]|\\.)*'")
! _dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"')
  
  def split_quoted (s):
--- 210,219 ----
  
  # Needed by 'split_quoted()'
! _wordchars_re = _squote_re = _dquote_re = None
! def _init_regex():
!     global _wordchars_re, _squote_re, _dquote_re
!     _wordchars_re = re.compile(r'[^\\\'\"%s ]*' % string.whitespace)
!     _squote_re = re.compile(r"'(?:[^'\\]|\\.)*'")
!     _dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"')
  
  def split_quoted (s):
***************
*** 228,231 ****
--- 231,235 ----
      # doesn't require character-by-character examination.  It was a little
      # bit of a brain-bender to get it working right, though...
+     if _wordchars_re is None: _init_regex()
  
      s = string.strip(s)




More information about the Python-checkins mailing list