Fix "invalid escape sequence" warning in Python 3.6

http://bugs.python.org/issue27364
This commit is contained in:
Tim Graham 2016-09-27 19:26:57 -04:00
parent 0a0fe292ec
commit 0c66b80a95
8 changed files with 11 additions and 11 deletions

View File

@ -71,7 +71,7 @@ def getrgb(color):
int(color[7:9], 16),
)
m = re.match("rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$", color)
m = re.match(r"rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$", color)
if m:
return (
int(m.group(1)),
@ -79,7 +79,7 @@ def getrgb(color):
int(m.group(3))
)
m = re.match("rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)$", color)
m = re.match(r"rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)$", color)
if m:
return (
int((int(m.group(1)) * 255) / 100.0 + 0.5),
@ -87,7 +87,7 @@ def getrgb(color):
int((int(m.group(3)) * 255) / 100.0 + 0.5)
)
m = re.match("hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)$", color)
m = re.match(r"hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)$", color)
if m:
from colorsys import hls_to_rgb
rgb = hls_to_rgb(
@ -101,7 +101,7 @@ def getrgb(color):
int(rgb[2] * 255 + 0.5)
)
m = re.match("rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$",
m = re.match(r"rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$",
color)
if m:
return (

View File

@ -39,7 +39,7 @@ def register(viewer, order=1):
def show(image, title=None, **options):
"""
r"""
Display a given image.
:param image: An image object.

View File

@ -32,7 +32,7 @@ class TestFileJpeg(PillowTestCase):
def test_sanity(self):
# internal version number
self.assertRegexpMatches(Image.core.jpeglib_version, "\d+\.\d+$")
self.assertRegexpMatches(Image.core.jpeglib_version, r"\d+\.\d+$")
im = Image.open(TEST_FILE)
im.load()

View File

@ -31,7 +31,7 @@ class TestFileJpeg2k(PillowTestCase):
def test_sanity(self):
# Internal version number
self.assertRegexpMatches(Image.core.jp2klib_version, '\d+\.\d+\.\d+$')
self.assertRegexpMatches(Image.core.jp2klib_version, r'\d+\.\d+\.\d+$')
im = Image.open('Tests/images/test-card-lossless.jp2')
px = im.load()

View File

@ -55,7 +55,7 @@ class TestFilePng(PillowTestCase):
# internal version number
self.assertRegexpMatches(
Image.core.zlib_version, "\d+\.\d+\.\d+(\.\d+)?$")
Image.core.zlib_version, r"\d+\.\d+\.\d+(\.\d+)?$")
test_file = self.tempfile("temp.png")

View File

@ -43,7 +43,7 @@ class TestImageCms(PillowTestCase):
self.assertEqual(list(map(type, v)), [str, str, str, str])
# internal version number
self.assertRegexpMatches(ImageCms.core.littlecms_version, "\d+\.\d+$")
self.assertRegexpMatches(ImageCms.core.littlecms_version, r"\d+\.\d+$")
self.skip_missing()
i = ImageCms.profileToProfile(hopper(), SRGB, SRGB)

View File

@ -46,7 +46,7 @@ try:
def test_sanity(self):
self.assertRegexpMatches(
ImageFont.core.freetype2_version, "\d+\.\d+\.\d+$")
ImageFont.core.freetype2_version, r"\d+\.\d+\.\d+$")
def test_font_properties(self):
ttf = ImageFont.truetype(FONT_PATH, FONT_SIZE)

View File

@ -680,7 +680,7 @@ class pil_build_ext(build_ext):
else:
return
for line in open(zlibfile).readlines():
m = re.match('#define\s+ZLIB_VERSION\s+"([^"]*)"', line)
m = re.match(r'#define\s+ZLIB_VERSION\s+"([^"]*)"', line)
if not m:
continue
if m.group(1) < "1.2.3":