Repository: psychopy/psychopy

Issue:
TESTS: lots of warnings due to the new string searching in the regex compiling
Some are to do with the new string searching in the regex compiling:
```
  /home/travis/build/peircej/psychopy/psychopy/tools/monitorunittools.py:293: DeprecationWarning: invalid escape sequence \[
    _lbr = '[\[\(]\s*'
```
I think forcing that into a "raw" string like this should fix that complaint `_lbr = r'[\[\(]\s*'` (note the r before the string) because the raw strings do not try to escape characters

@TEParsons maybe you could apply that and just check it doesn't break your string checks?



Discussion:

Resolving patch:
diff --git a/psychopy/colors.py b/psychopy/colors.py
--- a/psychopy/colors.py
+++ b/psychopy/colors.py
@@ -179,25 +179,25 @@
         "yellowgreen": (0.207843137254902, 0.607843137254902, -0.607843137254902, 1.0)
     }
 # Shorthand for common regexpressions
-_255 = '(\d|\d\d|1\d\d|2[0-4]\d|25[0-5])'
-_360 = '((\d|\d\d|[12]\d\d|3[0-5]\d)(\.\d)*|360|360\.0*)'
-_100 = '((\d|\d\d)(\.\d)*|100|100\.0*)'
-_1 = '(0|1|1.0*|0\.\d*)'
-_lbr = '[\[\(]\s*'
-_rbr = '\s*[\]\)]'
+_255 = r'(\d|\d\d|1\d\d|2[0-4]\d|25[0-5])'
+_360 = r'((\d|\d\d|[12]\d\d|3[0-5]\d)(\.\d)*|360|360\.0*)'
+_100 = r'((\d|\d\d)(\.\d)*|100|100\.0*)'
+_1 = r'(0|1|1.0*|0\.\d*)'
+_lbr = r'[\[\(]\s*'
+_rbr = r'\s*[\]\)]'
 # Dict of regexpressions for different formats
 colorSpaces = {
     'named': re.compile("|".join(list(colorNames))), # A named colour space
-    'hex': re.compile('#[\dabcdefABCDEF]{6}'), # Hex
-    'hexa': re.compile('#[\dabcdefABCDEF]{8}'), # Hex + alpha
-    'rgb': re.compile(_lbr+'\-?'+_1+',\s*'+'\-?'+_1+',\s*'+'\-?'+_1+_rbr), # RGB from -1 to 1
-    'rgba': re.compile(_lbr+'\-?'+_1+',\s*'+'\-?'+_1+',\s*'+'\-?'+_1+',\s*'+'\-?'+_1+_rbr),  # RGB + alpha from -1 to 1
-    'rgb1': re.compile(_lbr+_1+',\s*'+_1+',\s*'+_1+_rbr),  # RGB from 0 to 1
-    'rgba1': re.compile(_lbr+_1+',\s*'+_1+',\s*'+_1+',\s*'+_1+_rbr),  # RGB + alpha from 0 to 1
-    'rgb255': re.compile(_lbr+_255+',\s*'+_255+',\s*'+_255+_rbr), # RGB from 0 to 255
-    'rgba255': re.compile(_lbr+_255+',\s*'+_255+',\s*'+_255+',\s*'+_255+_rbr), # RGB + alpha from 0 to 255
-    'hsv': re.compile(_lbr+_360+'\°?'+',\s*'+_1+',\s*'+_1+_rbr), # HSV with hue from 0 to 360 and saturation/vibrancy from 0 to 1
-    'hsva': re.compile(_lbr+_360+'\°?'+',\s*'+_1+',\s*'+_1+',\s*'+_1+_rbr), # HSV with hue from 0 to 360 and saturation/vibrancy from 0 to 1 + alpha from 0 to 1
+    'hex': re.compile(r'#[\dabcdefABCDEF]{6}'), # Hex
+    'hexa': re.compile(r'#[\dabcdefABCDEF]{8}'), # Hex + alpha
+    'rgb': re.compile(_lbr+r'\-?'+_1+r',\s*'+r'\-?'+_1+r',\s*'+r'\-?'+_1+_rbr), # RGB from -1 to 1
+    'rgba': re.compile(_lbr+r'\-?'+_1+r',\s*'+r'\-?'+_1+r',\s*'+r'\-?'+_1+r',\s*'+r'\-?'+_1+_rbr),  # RGB + alpha from -1 to 1
+    'rgb1': re.compile(_lbr+_1+r',\s*'+_1+r',\s*'+_1+_rbr),  # RGB from 0 to 1
+    'rgba1': re.compile(_lbr+_1+r',\s*'+_1+r',\s*'+_1+r',\s*'+_1+_rbr),  # RGB + alpha from 0 to 1
+    'rgb255': re.compile(_lbr+_255+r',\s*'+_255+r',\s*'+_255+_rbr), # RGB from 0 to 255
+    'rgba255': re.compile(_lbr+_255+r',\s*'+_255+r',\s*'+_255+r',\s*'+_255+_rbr), # RGB + alpha from 0 to 255
+    'hsv': re.compile(_lbr+_360+r'\°?'+r',\s*'+_1+r',\s*'+_1+_rbr), # HSV with hue from 0 to 360 and saturation/vibrancy from 0 to 1
+    'hsva': re.compile(_lbr+_360+r'\°?'+r',\s*'+_1+r',\s*'+_1+r',\s*'+_1+_rbr), # HSV with hue from 0 to 360 and saturation/vibrancy from 0 to 1 + alpha from 0 to 1
 }
 
 
@@ -652,14 +652,14 @@ def hsv(self):
     def hsv(self, color):
         self.hsva = color
 
-_rec = '(\-4\.5|\-4\.4\d*|\-4\.[0-4]\d*|\-[0-3]\.\d*|\-[0-3]|0|0\.\d*|1|1\.0)' # -4.5 to 1
+_rec = r'(\-4\.5|\-4\.4\d*|\-4\.[0-4]\d*|\-[0-3]\.\d*|\-[0-3]|0|0\.\d*|1|1\.0)' # -4.5 to 1
 advancedSpaces = {
-    'rec709TF': re.compile(_lbr+_rec+',\s*'+_rec+',\s*'+_rec+_rbr), # rec709TF adjusted RGB from -4.5 to 1 + alpha from 0 to 1
-    'rec709TFa': re.compile(_lbr+_rec+',\s*'+_rec+',\s*'+_rec+',\s*'+_1+_rbr), # rec709TF adjusted RGB from -4.5 to 1 + alpha from 0 to 1
-    'srgbTF': re.compile(_lbr+'\-?'+_1+',\s*'+'\-?'+_1+',\s*'+'\-?'+_1+_rbr), # srgbTF from -1 to 1 + alpha from 0 to 1
-    'srgbTFa': re.compile(_lbr+'\-?'+_1+',\s*'+'\-?'+_1+',\s*'+'\-?'+_1+',\s*'+_1+_rbr), # srgbTF from -1 to 1 + alpha from 0 to 1
-    'lms': re.compile(_lbr + '\-?' + _1 + ',\s*' + '\-?' + _1 + ',\s*' + '\-?' + _1 + _rbr),  # LMS from -1 to 1
-    'lmsa': re.compile(_lbr + '\-?' + _1 + ',\s*' + '\-?' + _1 + ',\s*' + '\-?' + _1 + ',\s*' + '\-?' + _1 + _rbr),  # LMS + alpha from -1 to 1
+    'rec709TF': re.compile(_lbr+_rec+r',\s*'+_rec+r',\s*'+_rec+_rbr), # rec709TF adjusted RGB from -4.5 to 1 + alpha from 0 to 1
+    'rec709TFa': re.compile(_lbr+_rec+r',\s*'+_rec+r',\s*'+_rec+r',\s*'+_1+_rbr), # rec709TF adjusted RGB from -4.5 to 1 + alpha from 0 to 1
+    'srgbTF': re.compile(_lbr+r'\-?'+_1+r',\s*'+r'\-?'+_1+r',\s*'+r'\-?'+_1+_rbr), # srgbTF from -1 to 1 + alpha from 0 to 1
+    'srgbTFa': re.compile(_lbr+r'\-?'+_1+r',\s*'+r'\-?'+_1+r',\s*'+r'\-?'+_1+r',\s*'+_1+_rbr), # srgbTF from -1 to 1 + alpha from 0 to 1
+    'lms': re.compile(_lbr + r'\-?' + _1 + r',\s*' + r'\-?' + _1 + r',\s*' + r'\-?' + _1 + _rbr),  # LMS from -1 to 1
+    'lmsa': re.compile(_lbr + r'\-?' + _1 + r',\s*' + r'\-?' + _1 + r',\s*' + r'\-?' + _1 + r',\s*' + r'\-?' + _1 + _rbr),  # LMS + alpha from -1 to 1
 }
 
 
diff --git a/psychopy/tools/monitorunittools.py b/psychopy/tools/monitorunittools.py
--- a/psychopy/tools/monitorunittools.py
+++ b/psychopy/tools/monitorunittools.py
@@ -290,18 +290,18 @@ def useRetina(self):
         return False
 
 # Shorthand for common regexpressions
-_lbr = '[\[\(]\s*'
-_rbr = '\s*[\]\)]'
-_float = '\d*.?\d*?'
-_int = '\d*(.0*)?'
-_360 = '(\d|\d\d|[12]\d\d|3[0-5]\d|360).?\d*?'
+_lbr = r'[\[\(]\s*'
+_rbr = r'\s*[\]\)]'
+_float = r'\d*.?\d*?'
+_int = r'\d*(.0*)?'
+_360 = r'(\d|\d\d|[12]\d\d|3[0-5]\d|360).?\d*?'
 # Dict of regexpressions for different formats
 vectorSpaces = {
-    'pix': re.compile(_lbr+'('+'\-?'+_int+',\s*'+')*'+'\-?'+_int+_rbr),
-    'deg': re.compile(_lbr+'('+'\-?'+_360+',\s*'+')*'+'\-?'+_360+_rbr),
-    'cm': re.compile(_lbr+'('+'\-?'+_float+',\s*'+')*'+'\-?'+_float+_rbr),
-    'norm': re.compile(_lbr+'('+'\-?'+_float+',\s*'+')*'+'\-?'+_float+_rbr),
-    'height': re.compile(_lbr+'('+'\-?'+_float+',\s*'+')*'+'\-?'+_float+_rbr),
+    'pix': re.compile(_lbr+r'('+r'\-?'+_int+r',\s*'+r')*'+r'\-?'+_int+_rbr),
+    'deg': re.compile(_lbr+r'('+r'\-?'+_360+r',\s*'+r')*'+r'\-?'+_360+_rbr),
+    'cm': re.compile(_lbr+r'('+r'\-?'+_float+r',\s*'+r')*'+r'\-?'+_float+_rbr),
+    'norm': re.compile(_lbr+r'('+r'\-?'+_float+r',\s*'+r')*'+r'\-?'+_float+_rbr),
+    'height': re.compile(_lbr+r'('+r'\-?'+_float+r',\s*'+r')*'+r'\-?'+_float+_rbr),
 }
 
 class Vector(object):
diff --git a/psychopy/visual/basevisual.py b/psychopy/visual/basevisual.py
--- a/psychopy/visual/basevisual.py
+++ b/psychopy/visual/basevisual.py
@@ -170,6 +170,10 @@ def autoDraw(self, value):
             # remove from autodraw lists
             toDrawDepths.pop(toDraw.index(self))  # remove from depths
             toDraw.remove(self)  # remove from draw list
+            # Remove from editable list (if present)
+            for c in self.win._editableChildren:
+                if c() == self:
+                    self.win._editableChildren.remove(c)
             self.status = STOPPED
 
     def setAutoDraw(self, value, log=None):


Test patch: