Unnamed: 0 int64 0 10k | function stringlengths 79 138k | label stringclasses 20
values | info stringlengths 42 261 |
|---|---|---|---|
1,200 | def parse_char(txt):
if not txt: raise PreprocError("attempted to parse a null char")
if txt[0] != '\\':
return ord(txt)
c = txt[1]
if c == 'x':
if len(txt) == 4 and txt[3] in string.hexdigits: return int(txt[2:], 16)
return int(txt[2:], 16)
elif c.isdigit():
if c == '0' and len(txt)==2: return 0
for i i... | KeyError | dataset/ETHPy150Open appcelerator-archive/poc-nodejs-desktop/Resources/nodejs/builds/linux/node/lib/node/wafadmin/Tools/preproc.py/parse_char |
1,201 | def tokenize(s):
"""convert a string into a list of tokens (shlex.split does not apply to c/c++/d)"""
ret = []
for match in re_clexer.finditer(s):
m = match.group
for name in tok_types:
v = m(name)
if v:
if name == IDENT:
try: v = g_optrans[v]; name = OP
except __HOLE__:
# c++ specific
... | KeyError | dataset/ETHPy150Open appcelerator-archive/poc-nodejs-desktop/Resources/nodejs/builds/linux/node/lib/node/wafadmin/Tools/preproc.py/tokenize |
1,202 | def addlines(self, node):
self.currentnode_stack.append(node.parent)
filepath = node.abspath(self.env)
self.count_files += 1
if self.count_files > recursion_limit: raise PreprocError("recursion limit exceeded")
pc = self.parse_cache
debug('preproc: reading file %r', filepath)
try:
lns = pc[filepath]
... | KeyError | dataset/ETHPy150Open appcelerator-archive/poc-nodejs-desktop/Resources/nodejs/builds/linux/node/lib/node/wafadmin/Tools/preproc.py/c_parser.addlines |
1,203 | def start(self, node, env):
debug('preproc: scanning %s (in %s)', node.name, node.parent.name)
self.env = env
variant = node.variant(env)
bld = node.__class__.bld
try:
self.parse_cache = bld.parse_cache
except __HOLE__:
bld.parse_cache = {}
self.parse_cache = bld.parse_cache
self.addlines(node)... | AttributeError | dataset/ETHPy150Open appcelerator-archive/poc-nodejs-desktop/Resources/nodejs/builds/linux/node/lib/node/wafadmin/Tools/preproc.py/c_parser.start |
1,204 | def resolve_name(name):
ret = None
parts = name.split('.')
cursor = len(parts)
module_name = parts[:cursor]
last_exc = None
while cursor > 0:
try:
ret = __import__('.'.join(module_name))
break
except ImportError as exc:
last_exc = exc
... | AttributeError | dataset/ETHPy150Open circus-tent/circus/circus/tests/generic.py/resolve_name |
1,205 | def setup(self):
try:
global S3Storage
from depot.io.awss3 import S3Storage
except __HOLE__:
raise SkipTest('Boto not installed')
env = os.environ
access_key_id = env.get('AWS_ACCESS_KEY_ID')
secret_access_key = env.get('AWS_SECRET_ACCESS_KEY'... | ImportError | dataset/ETHPy150Open amol-/depot/tests/test_awss3_storage.py/TestS3FileStorage.setup |
1,206 | def wait_network_port_idle(port):
"""Wait network port idle.
return after 5 minutes or network port idle.
TCP connect close TIME_WAIT max 2MSL(2minutes)
:param port: network port
"""
for i in range(0, 30): # 5 minutes
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_S... | OSError | dataset/ETHPy150Open remyzane/flask-http-api/http_api/assist/coding.py/wait_network_port_idle |
1,207 | def test_forbidden(webapp):
try:
urlopen("%s/test_forbidden" % webapp.server.http.base)
except __HOLE__ as e:
assert e.code == 403
assert e.msg == "Forbidden"
else:
assert False | HTTPError | dataset/ETHPy150Open circuits/circuits/tests/web/test_exceptions.py/test_forbidden |
1,208 | def test_notfound(webapp):
try:
urlopen("%s/test_notfound" % webapp.server.http.base)
except __HOLE__ as e:
assert e.code == 404
assert e.msg == "Not Found"
else:
assert False | HTTPError | dataset/ETHPy150Open circuits/circuits/tests/web/test_exceptions.py/test_notfound |
1,209 | def test_contenttype(webapp):
try:
urlopen("%s/test_contenttype" % webapp.server.http.base)
except __HOLE__ as e:
assert e.code == 500
assert e.msg == "Internal Server Error"
assert "text/html" in e.headers.get("Content-Type")
else:
assert False | HTTPError | dataset/ETHPy150Open circuits/circuits/tests/web/test_exceptions.py/test_contenttype |
1,210 | def test_contenttype_json(webapp):
try:
urlopen("%s/test_contenttype_json" % webapp.server.http.base)
except __HOLE__ as e:
assert "json" in e.headers.get("Content-Type")
result = json.loads(e.read().decode("utf-8"))
assert result["code"] == 500
assert result["name"] == "... | HTTPError | dataset/ETHPy150Open circuits/circuits/tests/web/test_exceptions.py/test_contenttype_json |
1,211 | def test_contenttype_json_no_debug(webapp):
try:
f = urlopen("%s/test_contenttype_json_no_debug" %
webapp.server.http.base)
except __HOLE__ as e:
assert "json" in e.headers.get("Content-Type")
result = json.loads(e.read().decode("utf-8"))
assert result["code"]... | HTTPError | dataset/ETHPy150Open circuits/circuits/tests/web/test_exceptions.py/test_contenttype_json_no_debug |
1,212 | def _cross_val(data, est, cv, n_jobs):
"""Helper to compute cross validation."""
try:
from sklearn.model_selection import cross_val_score
except __HOLE__:
# XXX support sklearn < 0.18
from sklearn.cross_validation import cross_val_score
return np.mean(cross_val_score(est, data, c... | ImportError | dataset/ETHPy150Open mne-tools/mne-python/mne/cov.py/_cross_val |
1,213 | def _auto_low_rank_model(data, mode, n_jobs, method_params, cv,
stop_early=True, verbose=None):
"""compute latent variable models."""
method_params = cp.deepcopy(method_params)
iter_n_components = method_params.pop('iter_n_components')
if iter_n_components is None:
iter_... | ValueError | dataset/ETHPy150Open mne-tools/mne-python/mne/cov.py/_auto_low_rank_model |
1,214 | def _regularized_covariance(data, reg=None):
"""Compute a regularized covariance from data using sklearn.
Parameters
----------
data : ndarray, shape (n_channels, n_times)
Data for covariance estimation.
reg : float | str | None (default None)
If not None, allow regularization for c... | ImportError | dataset/ETHPy150Open mne-tools/mne-python/mne/cov.py/_regularized_covariance |
1,215 | def parse_arg(s):
try:
return json.loads(s)
except __HOLE__:
return s | ValueError | dataset/ETHPy150Open aerospike/aerospike-client-python/examples/client/scan_info.py/parse_arg |
1,216 | def main(argv=None):
if not argv:
argv = sys.argv
parser = E.OptionParser(
version="%prog version: $Id: data2histogram.py 2782 2009-09-10 11:40:29Z andreas $")
parser.add_option("-r", "--range", dest="range", type="string",
help="range to calculate histogram for.")
... | ValueError | dataset/ETHPy150Open CGATOxford/cgat/scripts/data2histogram.py/main |
1,217 | @signalcommand
@custom_transaction
def handle(self, *fixture_labels, **options):
""" Main method of a Django command """
from django.db.models import get_apps
from django.core import serializers
from django.conf import settings
self.style = no_style()
verbosity ... | SystemExit | dataset/ETHPy150Open django-extensions/django-extensions/django_extensions/management/commands/syncdata.py/Command.handle |
1,218 | def test_index_set_conversion(self):
try:
import AppKit
except __HOLE__:
from nose import SkipTest
raise SkipTest
from tinymail.ui_delegates import array_from_index_set
data = [
[],
[0],
[3],
[0, 1, 2],
... | ImportError | dataset/ETHPy150Open mgax/tinymail/src/tinymail/tests/test_indexsets.py/IndexSetConversionTest.test_index_set_conversion |
1,219 | def filenameToModule(fn):
"""
Given a filename, do whatever possible to return a module object matching
that file.
If the file in question is a module in Python path, properly import and
return that module. Otherwise, load the source manually.
@param fn: A filename.
@return: A module objec... | ValueError | dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/twisted/trial/runner.py/filenameToModule |
1,220 | def name(thing):
"""
@param thing: an object from modules (instance of PythonModule,
PythonAttribute), a TestCase subclass, or an instance of a TestCase.
"""
if isTestCase(thing):
# TestCase subclass
theName = reflect.qual(thing)
else:
# thing from trial, or thing fro... | AttributeError | dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/twisted/trial/runner.py/name |
1,221 | def isTestCase(obj):
"""
@return: C{True} if C{obj} is a class that contains test cases, C{False}
otherwise. Used to find all the tests in a module.
"""
try:
return issubclass(obj, pyunit.TestCase)
except __HOLE__:
return False | TypeError | dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/twisted/trial/runner.py/isTestCase |
1,222 | def _getDebugger(self):
dbg = pdb.Pdb()
try:
import readline
except ImportError:
print "readline module not available"
sys.exc_clear()
for path in ('.pdbrc', 'pdbrc'):
if os.path.exists(path):
try:
rcFile... | IOError | dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/twisted/trial/runner.py/TrialRunner._getDebugger |
1,223 | def parse_feature(obj):
""" Given a python object
attemp to a GeoJSON-like Feature from it
"""
# object implementing geo_interface
if hasattr(obj, '__geo_interface__'):
gi = obj.__geo_interface__
if gi['type'] in geom_types:
return wrap_geom(gi)
elif gi['type'] =... | TypeError | dataset/ETHPy150Open perrygeo/python-rasterstats/src/rasterstats/io.py/parse_feature |
1,224 | def read_features(obj, layer=0):
features_iter = None
if isinstance(obj, string_types):
try:
# test it as fiona data source
with fiona.open(obj, 'r', layer=layer) as src:
assert len(src) > 0
def fiona_generator(obj):
with fiona.open(ob... | OSError | dataset/ETHPy150Open perrygeo/python-rasterstats/src/rasterstats/io.py/read_features |
1,225 | def _modify_execution_status_in_database(
self, execution, new_status):
try:
execution_id = execution['id']
except __HOLE__:
execution_id = execution.id
storage_manager._get_instance().update_execution_status(
execution_id, new_status, error='')
... | TypeError | dataset/ETHPy150Open cloudify-cosmo/cloudify-manager/rest-service/manager_rest/test/test_executions.py/ExecutionsTestCase._modify_execution_status_in_database |
1,226 | def get_by_natural_key(self, app_label, model):
try:
ct = self._cache[self.db][(app_label, model)]
except __HOLE__:
ct = self.get(app_label=app_label, model=model)
self._add_to_cache(self.db, ct)
return ct | KeyError | dataset/ETHPy150Open django/django/django/contrib/contenttypes/models.py/ContentTypeManager.get_by_natural_key |
1,227 | def get_for_model(self, model, for_concrete_model=True):
"""
Returns the ContentType object for a given model, creating the
ContentType if necessary. Lookups are cached so that subsequent lookups
for the same model don't hit the database.
"""
opts = self._get_opts(model, ... | KeyError | dataset/ETHPy150Open django/django/django/contrib/contenttypes/models.py/ContentTypeManager.get_for_model |
1,228 | def get_for_models(self, *models, **kwargs):
"""
Given *models, returns a dictionary mapping {model: content_type}.
"""
for_concrete_models = kwargs.pop('for_concrete_models', True)
# Final results
results = {}
# models that aren't already in the cache
nee... | KeyError | dataset/ETHPy150Open django/django/django/contrib/contenttypes/models.py/ContentTypeManager.get_for_models |
1,229 | def get_for_id(self, id):
"""
Lookup a ContentType by ID. Uses the same shared cache as get_for_model
(though ContentTypes are obviously not created on-the-fly by get_by_id).
"""
try:
ct = self._cache[self.db][id]
except __HOLE__:
# This could rais... | KeyError | dataset/ETHPy150Open django/django/django/contrib/contenttypes/models.py/ContentTypeManager.get_for_id |
1,230 | def _log_context(self, context):
template = Template(self._get_template('context'))
keys = []
if isinstance(context, list):
for c in context:
keys += self._get_context_keys(c)
else:
keys += self._get_context_keys(context)
keys = set(keys)
... | UnicodeDecodeError | dataset/ETHPy150Open ericholscher/django-test-utils/test_utils/testmaker/processors/base.py/Processer._log_context |
1,231 | def format_citation_details(self, entry, citation_template=None):
"""Return string."""
if citation_template is None:
citation_template = self.citation_template
try:
type_template = citation_template[entry.entry_type] #:note: recall entry_type was stored as lowercase
except __HOLE__: #no template exists ... | KeyError | dataset/ETHPy150Open dschwilk/bibstuff/bibstuff/bibstyles/shared.py/EntryFormatter.format_citation_details |
1,232 | def filterbots(fh, ip_ua_re, bots_ua, bots_ips,
parser=None, format=None, ip_ua_fields=None,
reverse=False, debug=False, **kwargs):
"""Filter bots from a log stream using
ip/useragent blacklists"""
bots_ua_dict, bots_ua_prefix_dict, bots_ua_suffix_dict, bots_ua_re = \
... | ValueError | dataset/ETHPy150Open adamhadani/logtools/logtools/_filterbots.py/filterbots |
1,233 | def __init__(self, path, exclusive=False):
self.path = path
try:
self.fd = open(path, 'r+')
except IOError:
self.fd = open(path, 'r')
try:
if exclusive:
fcntl.lockf(self.fd, fcntl.LOCK_EX)
else:
fcntl.lockf(s... | IOError | dataset/ETHPy150Open jborg/attic/attic/helpers.py/UpgradableLock.__init__ |
1,234 | def upgrade(self):
try:
fcntl.lockf(self.fd, fcntl.LOCK_EX)
# Python 3.2 raises IOError, Python3.3+ raises OSError
except (__HOLE__, OSError):
raise self.WriteLockFailed(self.path)
self.is_exclusive = True | IOError | dataset/ETHPy150Open jborg/attic/attic/helpers.py/UpgradableLock.upgrade |
1,235 | def prune_within(archives, within):
multiplier = {'H': 1, 'd': 24, 'w': 24*7, 'm': 24*31, 'y': 24*365}
try:
hours = int(within[:-1]) * multiplier[within[-1]]
except (__HOLE__, ValueError):
# I don't like how this displays the original exception too:
raise argparse.ArgumentTypeError('... | KeyError | dataset/ETHPy150Open jborg/attic/attic/helpers.py/prune_within |
1,236 | def is_cachedir(path):
"""Determines whether the specified path is a cache directory (and
therefore should potentially be excluded from the backup) according to
the CACHEDIR.TAG protocol
(http://www.brynosaurus.com/cachedir/spec.html).
"""
tag_contents = b'Signature: 8a477f597d28d172789f0688680... | OSError | dataset/ETHPy150Open jborg/attic/attic/helpers.py/is_cachedir |
1,237 | def memoize(function):
cache = {}
def decorated_function(*args):
try:
return cache[args]
except __HOLE__:
val = function(*args)
cache[args] = val
return val
return decorated_function | KeyError | dataset/ETHPy150Open jborg/attic/attic/helpers.py/memoize |
1,238 | @memoize
def uid2user(uid, default=None):
try:
return pwd.getpwuid(uid).pw_name
except __HOLE__:
return default | KeyError | dataset/ETHPy150Open jborg/attic/attic/helpers.py/uid2user |
1,239 | @memoize
def user2uid(user, default=None):
try:
return user and pwd.getpwnam(user).pw_uid
except __HOLE__:
return default | KeyError | dataset/ETHPy150Open jborg/attic/attic/helpers.py/user2uid |
1,240 | @memoize
def gid2group(gid, default=None):
try:
return grp.getgrgid(gid).gr_name
except __HOLE__:
return default | KeyError | dataset/ETHPy150Open jborg/attic/attic/helpers.py/gid2group |
1,241 | @memoize
def group2gid(group, default=None):
try:
return group and grp.getgrnam(group).gr_gid
except __HOLE__:
return default | KeyError | dataset/ETHPy150Open jborg/attic/attic/helpers.py/group2gid |
1,242 | def location_validator(archive=None):
def validator(text):
try:
loc = Location(text)
except __HOLE__:
raise argparse.ArgumentTypeError('Invalid location format: "%s"' % text)
if archive is True and not loc.archive:
raise argparse.ArgumentTypeError('"%s": N... | ValueError | dataset/ETHPy150Open jborg/attic/attic/helpers.py/location_validator |
1,243 | def yield_timed_calls(filename):
try:
f = open(filename)
except __HOLE__, error:
print >> sys.stderr, "I/O error while opening file: %s" % error
return
for line in f:
try:
labels = line.split(':')[:3]
except Exception, error:
print >> sys.stde... | IOError | dataset/ETHPy150Open columbia/libtrack/libtrack/parser/scripts/patterns.py/yield_timed_calls |
1,244 | def visit_Call(self, node):
global game
if 'id' in dir(node.func):
self.stack.store()
if len(node.args) > 0:
self.generic_visit(node.args)
args = self.stack.current()
self.stack.wipe()
else:
args = []
... | TypeError | dataset/ETHPy150Open gutomaia/pyNES/pynes/composer.py/PyNesVisitor.visit_Call |
1,245 | def train(model, dataset, lr=1e-4, momentum=0.9,
batch_size=100, n_epochs=100, valid_freq=None,
patience_incr=2.0, lr_decr=0.5, epoch_waiting=10,
never_stop=False):
r"""Train the model with mini-batch Stochastic Gradient Descent(SGD).
Parameters
----------
model : NeuralNe... | KeyboardInterrupt | dataset/ETHPy150Open Cysu/dlearn/dlearn/optimization/sgd.py/train |
1,246 | def train_dp(model, data_provider, lr=1e-4, momentum=0.9,
n_epochs=100, valid_freq=None,
patience_incr=2.0, lr_decr=0.1, epoch_waiting=10,
never_stop=False):
r"""Train the model with mini-batch Stochastic Gradient Descent(SGD).
Parameters
----------
model : Neural... | KeyboardInterrupt | dataset/ETHPy150Open Cysu/dlearn/dlearn/optimization/sgd.py/train_dp |
1,247 | @staticmethod
def _parse(lines):
def coalesce_lines():
line_iter = iter(lines)
try:
buffer = ''
while True:
line = next(line_iter)
if line.strip().endswith('\\'):
# Continuation.
buffer += line.strip()[:-1]
else:
if buff... | StopIteration | dataset/ETHPy150Open pantsbuild/pants/src/python/pants/backend/jvm/tasks/properties.py/Properties._parse |
1,248 | def load_caffe(model_desc, model_file):
"""
return a dict of params
"""
param_dict = {}
param_processors = get_processor()
with change_env('GLOG_minloglevel', '2'):
import caffe
caffe.set_mode_cpu()
net = caffe.Net(model_desc, model_file, caffe.TEST)
layer_names = ne... | ValueError | dataset/ETHPy150Open ppwwyyxx/tensorpack/tensorpack/utils/loadcaffe.py/load_caffe |
1,249 | def get(self, key):
try:
expires, value = self._cache[key]
if expires == 0 or expires > time():
return pickle.loads(value)
except (__HOLE__, pickle.PickleError):
return None | KeyError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/SimpleCache.get |
1,250 | def has(self, key):
try:
expires, value = self._cache[key]
return expires == 0 or expires > time()
except __HOLE__:
return False | KeyError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/SimpleCache.has |
1,251 | def import_preferred_memcache_lib(self, servers):
"""Returns an initialized memcache client. Used by the constructor."""
try:
import pylibmc
except ImportError:
pass
else:
return pylibmc.Client(servers)
try:
from google.appengine.... | ImportError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/MemcachedCache.import_preferred_memcache_lib |
1,252 | def __init__(self, host='localhost', port=6379, password=None,
db=0, default_timeout=300, key_prefix=None, **kwargs):
BaseCache.__init__(self, default_timeout)
if isinstance(host, string_types):
try:
import redis
except __HOLE__:
r... | ImportError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/RedisCache.__init__ |
1,253 | def load_object(self, value):
"""The reversal of :meth:`dump_object`. This might be called with
None.
"""
if value is None:
return None
if value.startswith(b'!'):
try:
return pickle.loads(value[1:])
except pickle.PickleError:
... | ValueError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/RedisCache.load_object |
1,254 | def __init__(self, cache_dir, threshold=500, default_timeout=300,
mode=0o600):
BaseCache.__init__(self, default_timeout)
self._path = cache_dir
self._threshold = threshold
self._mode = mode
try:
os.makedirs(self._path)
except __HOLE__ as ex:
... | OSError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/FileSystemCache.__init__ |
1,255 | def _prune(self):
entries = self._list_dir()
if len(entries) > self._threshold:
now = time()
try:
for idx, fname in enumerate(entries):
remove = False
with open(fname, 'rb') as f:
expires = pickle.loa... | OSError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/FileSystemCache._prune |
1,256 | def clear(self):
for fname in self._list_dir():
try:
os.remove(fname)
except (__HOLE__, OSError):
return False
return True | IOError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/FileSystemCache.clear |
1,257 | def get(self, key):
filename = self._get_filename(key)
try:
with open(filename, 'rb') as f:
pickle_time = pickle.load(f)
if pickle_time == 0 or pickle_time >= time():
return pickle.load(f)
else:
os.remove... | OSError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/FileSystemCache.get |
1,258 | def set(self, key, value, timeout=None):
if timeout is None:
timeout = int(time() + self.default_timeout)
elif timeout != 0:
timeout = int(time() + timeout)
filename = self._get_filename(key)
self._prune()
try:
fd, tmp = tempfile.mkstemp(suffix... | IOError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/FileSystemCache.set |
1,259 | def delete(self, key):
try:
os.remove(self._get_filename(key))
except (__HOLE__, OSError):
return False
else:
return True | IOError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/FileSystemCache.delete |
1,260 | def has(self, key):
filename = self._get_filename(key)
try:
with open(filename, 'rb') as f:
pickle_time = pickle.load(f)
if pickle_time == 0 or pickle_time >= time():
return True
else:
os.remove(filename)... | IOError | dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/werkzeug/contrib/cache.py/FileSystemCache.has |
1,261 | def consume_batch_async(self, batch):
op = self.operation()
op_mutate = op in ['set', 'add']
stdout = sys.stdout
msg_visitor = None
opts_etc = getattr(self.opts, "etc", None)
if opts_etc:
stdout = opts_etc.get("stdout", sys.stdout)
msg_visitor = ... | IOError | dataset/ETHPy150Open membase/membase-cli/pump.py/StdOutSink.consume_batch_async |
1,262 | def rest_request_json(host, port, user, pswd, path, reason=''):
err, conn, rest_json = rest_request(host, port, user, pswd, path,
reason=reason)
if err:
return err, None, None
if conn:
conn.close()
try:
return None, rest_json, json.loads(re... | ValueError | dataset/ETHPy150Open membase/membase-cli/pump.py/rest_request_json |
1,263 | def parse(self, timestr, default=None, ignoretz=False, settings=None, **kwargs):
# timestr needs to be a buffer as required by _parse
if isinstance(timestr, binary_type):
timestr = timestr.decode()
# Parse timestr
# handle dateutil>=2.5 tuple result first
try:
... | TypeError | dataset/ETHPy150Open scrapinghub/dateparser/dateparser/date_parser.py/new_parser.parse |
1,264 | def dateutil_parse(date_string, settings=None, **kwargs):
"""Wrapper function around dateutil.parser.parse
"""
today = datetime.utcnow()
kwargs.update(default=today)
date_string = re.sub(r'\b(year|month|week|day)\b', '', date_string, re.I)
# XXX: this is needed because of a bug in dateutil.pars... | TypeError | dataset/ETHPy150Open scrapinghub/dateparser/dateparser/date_parser.py/dateutil_parse |
1,265 | def _format_external_gateway_info(info):
try:
return json.dumps(info)
except (__HOLE__, KeyError):
return '' | TypeError | dataset/ETHPy150Open dtroyer/python-openstackclient/openstackclient/network/v2/router.py/_format_external_gateway_info |
1,266 | def main():
class MyParser(argparse.ArgumentParser):
def error(self, message):
sys.stderr.write('error: {0}\n'.format(message))
self.print_help()
sys.exit(2)
class AppendDictAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=... | KeyboardInterrupt | dataset/ETHPy150Open ralphje/imagemounter/imagemounter/imount.py/main |
1,267 | def lookup_id(self, id):
try:
return self.Identities[id]
except __HOLE__:
if self.fallback:
return self.fallback.lookup_id(id)
else:
return None | KeyError | dataset/ETHPy150Open antong/ldaptor/ldaptor/protocols/pureber.py/BERDecoderContext.lookup_id |
1,268 | def test_is_length_failure(self):
try:
assert_that('foo').is_length(4)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('Expected <foo> to be of length <4>, but was <3>.') | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_is_length_failure |
1,269 | def test_contains_single_item_failure(self):
try:
assert_that('foo').contains('x')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('Expected <foo> to contain item <x>, but did not.') | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_contains_single_item_failure |
1,270 | def test_contains_multi_item_failure(self):
try:
assert_that('foo').contains('f','x','z')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to("Expected <foo> to contain items ('f', 'x', 'z'), but did not contain <x>.") | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_contains_multi_item_failure |
1,271 | def test_contains_ignoring_case_type_failure(self):
try:
assert_that(123).contains_ignoring_case('f')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('val is not a string') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_contains_ignoring_case_type_failure |
1,272 | def test_contains_ignoring_case_missinge_item_failure(self):
try:
assert_that('foo').contains_ignoring_case()
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('one or more args must be given') | ValueError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_contains_ignoring_case_missinge_item_failure |
1,273 | def test_contains_ignoring_case_single_item_failure(self):
try:
assert_that('foo').contains_ignoring_case('X')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('Expected <foo> to case-insensitive contain item <X>, but did not.') | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_contains_ignoring_case_single_item_failure |
1,274 | def test_contains_ignoring_case_single_item_type_failure(self):
try:
assert_that('foo').contains_ignoring_case(12)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('given arg must be a string') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_contains_ignoring_case_single_item_type_failure |
1,275 | def test_contains_ignoring_case_multi_item_failure(self):
try:
assert_that('foo').contains_ignoring_case('F','X','Z')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to("Expected <foo> to case-insensitive contain items ('F', 'X', ... | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_contains_ignoring_case_multi_item_failure |
1,276 | def test_contains_ignoring_case_multi_item_type_failure(self):
try:
assert_that('foo').contains_ignoring_case('F', 12)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('given args must all be strings') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_contains_ignoring_case_multi_item_type_failure |
1,277 | def test_does_not_contain_single_item_failure(self):
try:
assert_that('foo').does_not_contain('f')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('Expected <foo> to not contain item <f>, but did.') | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_does_not_contain_single_item_failure |
1,278 | def test_does_not_contain_list_item_failure(self):
try:
assert_that('foo').does_not_contain('x','y','f')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to("Expected <foo> to not contain items ('x', 'y', 'f'), but did contain <f>.... | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_does_not_contain_list_item_failure |
1,279 | def test_is_empty_failure(self):
try:
assert_that('foo').is_empty()
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('Expected <foo> to be empty string, but was not.') | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_is_empty_failure |
1,280 | def test_is_not_empty_failure(self):
try:
assert_that('').is_not_empty()
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('Expected not empty string, but was empty.') | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_is_not_empty_failure |
1,281 | def test_is_equal_ignoring_case_failure(self):
try:
assert_that('foo').is_equal_to_ignoring_case('bar')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('Expected <foo> to be case-insensitive equal to <bar>, but was not.') | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_is_equal_ignoring_case_failure |
1,282 | def test_is_equal_ignoring_case_bad_value_type_failure(self):
try:
assert_that(123).is_equal_to_ignoring_case(12)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('val is not a string') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_is_equal_ignoring_case_bad_value_type_failure |
1,283 | def test_is_equal_ignoring_case_bad_arg_type_failure(self):
try:
assert_that('fred').is_equal_to_ignoring_case(12)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('given arg must be a string') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_is_equal_ignoring_case_bad_arg_type_failure |
1,284 | def test_starts_with_failure(self):
try:
assert_that('fred').starts_with('bar')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('Expected <fred> to start with <bar>, but did not.') | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_starts_with_failure |
1,285 | def test_starts_with_bad_value_type_failure(self):
try:
assert_that(123).starts_with(12)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('val is not a string or iterable') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_starts_with_bad_value_type_failure |
1,286 | def test_starts_with_bad_arg_none_failure(self):
try:
assert_that('fred').starts_with(None)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('given prefix arg must not be none') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_starts_with_bad_arg_none_failure |
1,287 | def test_starts_with_bad_arg_type_failure(self):
try:
assert_that('fred').starts_with(123)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('given prefix arg must be a string') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_starts_with_bad_arg_type_failure |
1,288 | def test_starts_with_bad_arg_empty_failure(self):
try:
assert_that('fred').starts_with('')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('given prefix arg must not be empty') | ValueError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_starts_with_bad_arg_empty_failure |
1,289 | def test_ends_with_failure(self):
try:
assert_that('fred').ends_with('bar')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('Expected <fred> to end with <bar>, but did not.') | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_ends_with_failure |
1,290 | def test_ends_with_bad_value_type_failure(self):
try:
assert_that(123).ends_with(12)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('val is not a string or iterable') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_ends_with_bad_value_type_failure |
1,291 | def test_ends_with_bad_arg_none_failure(self):
try:
assert_that('fred').ends_with(None)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('given suffix arg must not be none') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_ends_with_bad_arg_none_failure |
1,292 | def test_ends_with_bad_arg_type_failure(self):
try:
assert_that('fred').ends_with(123)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('given suffix arg must be a string') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_ends_with_bad_arg_type_failure |
1,293 | def test_ends_with_bad_arg_empty_failure(self):
try:
assert_that('fred').ends_with('')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('given suffix arg must not be empty') | ValueError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_ends_with_bad_arg_empty_failure |
1,294 | def test_matches_failure(self):
try:
assert_that('fred').matches('\d+')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('Expected <fred> to match pattern <\d+>, but did not.') | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_matches_failure |
1,295 | def test_matches_bad_value_type_failure(self):
try:
assert_that(123).matches(12)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('val is not a string') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_matches_bad_value_type_failure |
1,296 | def test_matches_bad_arg_type_failure(self):
try:
assert_that('fred').matches(123)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('given pattern arg must be a string') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_matches_bad_arg_type_failure |
1,297 | def test_matches_bad_arg_empty_failure(self):
try:
assert_that('fred').matches('')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('given pattern arg must not be empty') | ValueError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_matches_bad_arg_empty_failure |
1,298 | def test_does_not_match_failure(self):
try:
assert_that('fred').does_not_match('\w+')
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('Expected <fred> to not match pattern <\w+>, but did.') | AssertionError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_does_not_match_failure |
1,299 | def test_does_not_match_bad_value_type_failure(self):
try:
assert_that(123).does_not_match(12)
fail('should have raised error')
except __HOLE__ as ex:
assert_that(str(ex)).is_equal_to('val is not a string') | TypeError | dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_string.py/TestString.test_does_not_match_bad_value_type_failure |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.