Merge "py27: Suppress UnicodeWarnings in ShardRange setters"
This commit is contained in:
commit
08db36a295
@ -48,6 +48,7 @@ import ctypes.util
|
||||
from copy import deepcopy
|
||||
from optparse import OptionParser
|
||||
import traceback
|
||||
import warnings
|
||||
|
||||
from tempfile import gettempdir, mkstemp, NamedTemporaryFile
|
||||
import glob
|
||||
@ -4985,8 +4986,10 @@ class ShardRange(object):
|
||||
|
||||
@lower.setter
|
||||
def lower(self, value):
|
||||
if value in (None, b'', u''):
|
||||
value = ShardRange.MIN
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore', UnicodeWarning)
|
||||
if value in (None, b'', u''):
|
||||
value = ShardRange.MIN
|
||||
try:
|
||||
value = self._encode_bound(value)
|
||||
except TypeError as err:
|
||||
@ -5011,8 +5014,10 @@ class ShardRange(object):
|
||||
|
||||
@upper.setter
|
||||
def upper(self, value):
|
||||
if value in (None, b'', u''):
|
||||
value = ShardRange.MAX
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore', UnicodeWarning)
|
||||
if value in (None, b'', u''):
|
||||
value = ShardRange.MAX
|
||||
try:
|
||||
value = self._encode_bound(value)
|
||||
except TypeError as err:
|
||||
|
@ -44,6 +44,7 @@ import sys
|
||||
import json
|
||||
import math
|
||||
import inspect
|
||||
import warnings
|
||||
|
||||
import six
|
||||
from six import StringIO
|
||||
@ -7585,8 +7586,10 @@ class TestShardRange(unittest.TestCase):
|
||||
expected = u'\N{SNOWMAN}'
|
||||
if six.PY2:
|
||||
expected = expected.encode('utf-8')
|
||||
do_test(u'\N{SNOWMAN}', expected)
|
||||
do_test(u'\N{SNOWMAN}'.encode('utf-8'), expected)
|
||||
with warnings.catch_warnings(record=True) as captured_warnings:
|
||||
do_test(u'\N{SNOWMAN}', expected)
|
||||
do_test(u'\N{SNOWMAN}'.encode('utf-8'), expected)
|
||||
self.assertFalse(captured_warnings)
|
||||
|
||||
sr = utils.ShardRange('a/c', utils.Timestamp.now(), 'b', 'y')
|
||||
sr.lower = ''
|
||||
@ -7633,8 +7636,10 @@ class TestShardRange(unittest.TestCase):
|
||||
expected = u'\N{SNOWMAN}'
|
||||
if six.PY2:
|
||||
expected = expected.encode('utf-8')
|
||||
do_test(u'\N{SNOWMAN}', expected)
|
||||
do_test(u'\N{SNOWMAN}'.encode('utf-8'), expected)
|
||||
with warnings.catch_warnings(record=True) as captured_warnings:
|
||||
do_test(u'\N{SNOWMAN}', expected)
|
||||
do_test(u'\N{SNOWMAN}'.encode('utf-8'), expected)
|
||||
self.assertFalse(captured_warnings)
|
||||
|
||||
sr = utils.ShardRange('a/c', utils.Timestamp.now(), 'b', 'y')
|
||||
sr.upper = ''
|
||||
|
Loading…
x
Reference in New Issue
Block a user