gurudesh/pytracebugs huggingface dataset:
# Buggy code
def __init__(self, model, hidden_dim=None, prefix="auto"):
    self.hidden_dim = hidden_dim
    self.arn = None
    super(AutoIAFNormal, self).__init__(model, prefix)


# Traceback (RuntimeError)
Traceback (most recent call last):
File "C:\tools\miniconda3\envs\scanner-pyro\lib\site-packages\IPython\core\interactiveshell.py", line 3265, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-6-68d49e4377f9>", line 26, in <module>
train()
File "<ipython-input-6-68d49e4377f9>", line 23, in train
svi.step(xs, prior_loc, prior_scale)
File "C:\tools\miniconda3\envs\scanner-pyro\lib\site-packages\pyro\infer\svi.py", line 99, in step
loss = self.loss_and_grads(self.model, self.guide, *args, **kwargs)
File "C:\tools\miniconda3\envs\scanner-pyro\lib\site-packages\pyro\infer\trace_elbo.py", line 136, in loss_and_grads
surrogate_loss_particle.backward(retain_graph=self.retain_graph)
File "C:\tools\miniconda3\envs\scanner-pyro\lib\site-packages\torch\tensor.py", line 107, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "C:\tools\miniconda3\envs\scanner-pyro\lib\site-packages\torch\autograd\__init__.py", line 93, in backward
allow_unreachable=True)  # allow_unreachable flag
RuntimeError: Function AddBackward0 returned an invalid gradient at index 1 - expected type torch.cuda.FloatTensor but got torch.FloatTensor

# Fixed code
def __init__(self, model, hidden_dim=None, prefix="auto", init_loc_fn=init_to_median):
    self.hidden_dim = hidden_dim
    self.arn = None
    super(AutoIAFNormal, self).__init__(model, prefix=prefix, init_loc_fn=init_loc_fn)
# Buggy code
def get_posterior(self, *args, **kwargs):
    """
    Returns a Delta posterior distribution for MAP inference.
    """
    loc = pyro.param("{}_loc".format(self.prefix), lambda: torch.zeros(self.latent_dim))
    return dist.Delta(loc).to_event(1)


# Traceback (RuntimeError)
Traceback (most recent call last):
File "C:\tools\miniconda3\envs\scanner-pyro\lib\site-packages\IPython\core\interactiveshell.py", line 3265, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-6-68d49e4377f9>", line 26, in <module>
train()
File "<ipython-input-6-68d49e4377f9>", line 23, in train
svi.step(xs, prior_loc, prior_scale)
File "C:\tools\miniconda3\envs\scanner-pyro\lib\site-packages\pyro\infer\svi.py", line 99, in step
loss = self.loss_and_grads(self.model, self.guide, *args, **kwargs)
File "C:\tools\miniconda3\envs\scanner-pyro\lib\site-packages\pyro\infer\trace_elbo.py", line 136, in loss_and_grads
surrogate_loss_particle.backward(retain_graph=self.retain_graph)
File "C:\tools\miniconda3\envs\scanner-pyro\lib\site-packages\torch\tensor.py", line 107, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "C:\tools\miniconda3\envs\scanner-pyro\lib\site-packages\torch\autograd\__init__.py", line 93, in backward
allow_unreachable=True)  # allow_unreachable flag
RuntimeError: Function AddBackward0 returned an invalid gradient at index 1 - expected type torch.cuda.FloatTensor but got torch.FloatTensor

# Fixed code
def get_posterior(self, *args, **kwargs):
    """
    Returns a Delta posterior distribution for MAP inference.
    """
    loc = pyro.param("{}_loc".format(self.prefix), self._init_loc)
    return dist.Delta(loc).to_event(1)
# Buggy code
def model_sample(self, ys, batch_size=1):
    # sample the handwriting style from the constant prior distribution
    prior_mu = Variable(torch.zeros([batch_size, self.z_dim]))
    prior_sigma = Variable(torch.ones([batch_size, self.z_dim]))
    zs = pyro.sample("z", dist.normal, prior_mu, prior_sigma)

    # sample an image using the decoder
    mu = self.decoder.forward([zs, ys])
    xs = pyro.sample("sample", dist.bernoulli, mu)
    return xs, mu


# Traceback (NotImplementedError)
$ python ss_vae_M2.py -enum
Traceback (most recent call last):
File "ss_vae_M2.py", line 464, in <module>
run_inference_ss_vae(args)
File "ss_vae_M2.py", line 371, in run_inference_ss_vae
run_inference_for_epoch(data_loaders, losses, periodic_interval_batches)
File "ss_vae_M2.py", line 268, in run_inference_for_epoch
new_loss = losses[loss_id].step(xs)
File "/home/jbaik/.pyenv/versions/3.6.4/lib/python3.6/site-packages/pyro_ppl-0.1.2-py3.6.egg/pyro/infer/svi.py", line 98, in step
loss = self.loss_and_grads(self.model, self.guide, *args, **kwargs)
File "/home/jbaik/.pyenv/versions/3.6.4/lib/python3.6/site-packages/pyro_ppl-0.1.2-py3.6.egg/pyro/infer/elbo.py", line 65, in loss_and_grads
return self.which_elbo.loss_and_grads(model, guide, *args, **kwargs)
File "/home/jbaik/.pyenv/versions/3.6.4/lib/python3.6/site-packages/pyro_ppl-0.1.2-py3.6.egg/pyro/infer/trace_elbo.py", line 146, in loss_and_grads
for weight, model_trace, guide_trace, log_r in self._get_traces(model, guide, *args, **kwargs):
File "/home/jbaik/.pyenv/versions/3.6.4/lib/python3.6/site-packages/pyro_ppl-0.1.2-py3.6.egg/pyro/infer/trace_elbo.py", line 79, in _get_traces
check_enum_discrete_can_run(model_trace, guide_trace)
File "/home/jbaik/.pyenv/versions/3.6.4/lib/python3.6/site-packages/pyro_ppl-0.1.2-py3.6.egg/pyro/infer/trace_elbo.py", line 45, in check_enum_discrete_can_run
for shape, (source, name) in sorted(shapes.items())])))
NotImplementedError: enum_discrete does not support mixture of batched and un-batched variables. Try rewriting your model to avoid batching or running with enum_discrete=False. Found the following variables of different batch shapes:
guide y: shape = (200,)
guide z: shape = (200, 50)
model x: shape = (200, 784)

# Fixed code
def model_sample(self, ys, batch_size=1):
    # sample the handwriting style from the constant prior distribution
    prior_mu = Variable(torch.zeros([batch_size, self.z_dim]))
    prior_sigma = Variable(torch.ones([batch_size, self.z_dim]))
    zs = pyro.sample("z", dist.normal, prior_mu, prior_sigma, extra_event_dims=1)

    # sample an image using the decoder
    mu = self.decoder.forward([zs, ys])
    xs = pyro.sample("sample", dist.bernoulli, mu, extra_event_dims=1)
    return xs, mu
# Buggy code
def torch_multinomial(input, num_samples, replacement=False):
    """
    Like `torch.multinomial()` but works with cuda tensors.
    Does not support keyword argument `out`.
    """
    if input.is_cuda:
        return torch_multinomial(input.cpu(), num_samples, replacement).cuda()
    else:
        return torch.multinomial(input, num_samples, replacement)


# Traceback (RuntimeError)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-31-93fd337a0d5c> in <module>()
----> 1 train()

<ipython-input-30-98110a9a9720> in train()
33
34             # Train and score
---> 35             train_loss += svi.step(input_batch, target_batch)
36
37         # Store history

/home/reinier/anaconda2/lib/python2.7/site-packages/pyro/infer/svi.pyc in step(self, *args, **kwargs)
96         """
97         # get loss and compute gradients
---> 98         loss = self.loss_and_grads(self.model, self.guide, *args, **kwargs)
99
100         # get active params

/home/reinier/anaconda2/lib/python2.7/site-packages/pyro/infer/elbo.pyc in loss_and_grads(self, model, guide, *args, **kwargs)
63         :rtype: float
64         """
---> 65         return self.which_elbo.loss_and_grads(model, guide, *args, **kwargs)

/home/reinier/anaconda2/lib/python2.7/site-packages/pyro/infer/trace_elbo.pyc in loss_and_grads(self, model, guide, *args, **kwargs)
149                         guide_site = guide_trace.nodes[name]
150                         lp_lq = model_site[log_pdf] - guide_site[log_pdf]
--> 151                         elbo_particle += lp_lq
152                         if guide_site["fn"].reparameterized:
153                             surrogate_elbo_particle += lp_lq

RuntimeError: Expected object of type Variable[torch.FloatTensor] but found type Variable[torch.cuda.FloatTensor] for argument #1 'other'

# Fixed code
def torch_multinomial(input, num_samples, replacement=False):
    """
    Like `torch.multinomial()` but works with cuda tensors.
    Does not support keyword argument `out`.
    """
    if input.is_cuda:
        return torch.multinomial(input.cpu(), num_samples, replacement).cuda(
            input.get_device()
        )
    else:
        return torch.multinomial(input, num_samples, replacement)
# Buggy code
def resolve_is_lower_case(tokenizer):
    if isinstance(
        tokenizer, (transformers.BertTokenizer, transformers.AlbertTokenizer)
    ):
        return tokenizer.basic_tokenizer.do_lower_case
    else:
        return False


# Traceback (ValueError)
Traceback (most recent call last):
File "/scratch/pmh330/nyu-mll-jiant/jiant/jiant/proj/main/tokenize_and_cache.py", line 214, in <module>
main(args=RunConfiguration.run_cli_json_prepend())
File "/scratch/pmh330/nyu-mll-jiant/jiant/jiant/proj/main/tokenize_and_cache.py", line 168, in main
args=args,
File "/scratch/pmh330/nyu-mll-jiant/jiant/jiant/proj/main/tokenize_and_cache.py", line 53, in chunk_and_save
args=args,
File "/scratch/pmh330/nyu-mll-jiant/jiant/jiant/proj/main/tokenize_and_cache.py", line 129, in iter_chunk_and_save
recorder_callback=max_valid_length_recorder,
File "/scratch/pmh330/nyu-mll-jiant/jiant/jiant/shared/caching.py", line 91, in iter_chunk_and_save
for datum in data:
File "/scratch/pmh330/nyu-mll-jiant/jiant/jiant/proj/main/preprocessing.py", line 145, in iter_chunk_convert_examples_to_dataset
verbose=verbose,
File "/scratch/pmh330/nyu-mll-jiant/jiant/jiant/proj/main/preprocessing.py", line 216, in iter_chunk_tokenize_and_featurize
yield example.tokenize(tokenizer).featurize(tokenizer, feat_spec)
File "/scratch/pmh330/nyu-mll-jiant/jiant/jiant/tasks/lib/templates/span_prediction.py", line 38, in tokenize
self.answer_char_span[0], self.answer_char_span[1], inclusive=True
File "/scratch/pmh330/nyu-mll-jiant/jiant/jiant/utils/retokenize.py", line 276, in project_char_to_token_span
mat=self.source_char_idx_to_target_token_idx, start=start, end=end, inclusive=inclusive
File "/scratch/pmh330/nyu-mll-jiant/jiant/jiant/utils/retokenize.py", line 192, in _project_span
raise ValueError(f"Project {(start, end)} into empty span in target sequence")
ValueError: Project (0, 2) into empty span in target sequence

# Fixed code
def resolve_is_lower_case(tokenizer):
    if isinstance(tokenizer, transformers.BertTokenizer):
        return tokenizer.basic_tokenizer.do_lower_case
    if isinstance(tokenizer, transformers.AlbertTokenizer):
        return tokenizer.do_lower_case
    else:
        return False
# Buggy code
def make_one_hot(batch, depth=2):
    """
    Creates a one-hot embedding of dimension 2.
    Parameters:
    batch: list of size batch_size of class predictions
    Returns:
    one hot encoding of size [batch_size, 2]
    """
    ones = torch.sparse.torch.eye(depth).cuda()
    return ones.index_select(0, batch)


# Traceback (ValueError)
Traceback (most recent call last):
File "main.py", line 566, in <module>
main(sys.argv[1:])
File "main.py", line 534, in main
phase="target_train",
File "/Users/srbowman/jiant/src/trainer.py", line 594, in train
output_dict = self._forward(batch, task=task)
File "/Users/srbowman/jiant/src/trainer.py", line 1035, in _forward
model_out = self._model.forward(task, tensor_batch)
File "/Users/srbowman/jiant/src/models.py", line 830, in forward
out = self._span_forward(batch, task, predict)
File "/Users/srbowman/jiant/src/models.py", line 917, in _span_forward
out = module.forward(batch, sent_embs, sent_mask, task, predict)
File "/Users/srbowman/jiant/src/modules/span_modules.py", line 134, in forward
out["loss"] = self.compute_loss(logits, batch["labels"].squeeze(dim=1), task)
File "/Users/srbowman/jiant/src/modules/span_modules.py", line 184, in compute_loss
raise ValueError("Unsupported loss type '%s' " "for edge probing." % self.loss_type)
ValueError: Unsupported loss type '' for edge probing.
Traceback (most recent call last):
File "main.py", line 577, in <module>
raise e  # re-raise exception, in case debugger is attached.
File "main.py", line 566, in <module>
main(sys.argv[1:])
File "main.py", line 534, in main
phase="target_train",
File "/Users/srbowman/jiant/src/trainer.py", line 594, in train
output_dict = self._forward(batch, task=task)
File "/Users/srbowman/jiant/src/trainer.py", line 1035, in _forward
model_out = self._model.forward(task, tensor_batch)
File "/Users/srbowman/jiant/src/models.py", line 830, in forward
out = self._span_forward(batch, task, predict)
File "/Users/srbowman/jiant/src/models.py", line 917, in _span_forward
out = module.forward(batch, sent_embs, sent_mask, task, predict)
File "/Users/srbowman/jiant/src/modules/span_modules.py", line 134, in forward
out["loss"] = self.compute_loss(logits, batch["labels"].squeeze(dim=1), task)
File "/Users/srbowman/jiant/src/modules/span_modules.py", line 184, in compute_loss
raise ValueError("Unsupported loss type '%s' " "for edge probing." % self.loss_type)
ValueError: Unsupported loss type '' for edge probing.

# Fixed code
def make_one_hot(batch, depth=2):
    """
    Creates a one-hot embedding of dimension 2.
    Parameters:
    batch: list of size batch_size of class predictions
    Returns:
    one hot encoding of size [batch_size, 2]
    """
    ones = torch.sparse.torch.eye(depth)
    if torch.cuda.is_available():
        ones = ones.cuda()
    return ones.index_select(0, batch)
# Buggy code
def parse(self, file):
    data = []
    file = io.TextIOWrapper(file, encoding="utf-8")

    # Add check exception

    field_parsers = {
        "ne": lambda line, i: conllu.parser.parse_nullable_value(line[i]),
    }

    gen_parser = conllu.parse_incr(
        file, fields=("form", "ne"), field_parsers=field_parsers
    )

    try:
        for sentence in gen_parser:
            if not sentence:
                continue
            if len(data) >= settings.IMPORT_BATCH_SIZE:
                yield data
                data = []
            words, labels = [], []
            for item in sentence:
                word = item.get("form")
                tag = item.get("ne")

                if tag is not None:
                    char_left = sum(map(len, words)) + len(words)
                    char_right = char_left + len(word)
                    span = [char_left, char_right, tag]
                    labels.append(span)

                words.append(word)

            # Create and add JSONL
            data.append({"text": " ".join(words), "labels": labels})

    except conllu.parser.ParseException as e:
        raise FileParseException(line_num=-1, line=str(e))

    if data:
        yield data


# Traceback (UnicodeDecodeError)
Traceback (most recent call last):
File "/app/server/views.py", line 121, in post
documents = self.csv_to_documents(project, file)
File "/app/server/views.py", line 77, in csv_to_documents
maybe_header = next(reader)
File "/virtualenvs/doccano-HEgudFLz/bin/../lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

# Fixed code
def parse(self, file):
    data = []
    file = EncodedIO(file)
    file = io.TextIOWrapper(file, encoding=file.encoding)

    # Add check exception

    field_parsers = {
        "ne": lambda line, i: conllu.parser.parse_nullable_value(line[i]),
    }

    gen_parser = conllu.parse_incr(
        file, fields=("form", "ne"), field_parsers=field_parsers
    )

    try:
        for sentence in gen_parser:
            if not sentence:
                continue
            if len(data) >= settings.IMPORT_BATCH_SIZE:
                yield data
                data = []
            words, labels = [], []
            for item in sentence:
                word = item.get("form")
                tag = item.get("ne")

                if tag is not None:
                    char_left = sum(map(len, words)) + len(words)
                    char_right = char_left + len(word)
                    span = [char_left, char_right, tag]
                    labels.append(span)

                words.append(word)

            # Create and add JSONL
            data.append({"text": " ".join(words), "labels": labels})

    except conllu.parser.ParseException as e:
        raise FileParseException(line_num=-1, line=str(e))

    if data:
        yield data
# Buggy code
def parse(self, file):
    file = io.TextIOWrapper(file, encoding="utf-8")
    while True:
        batch = list(itertools.islice(file, settings.IMPORT_BATCH_SIZE))
        if not batch:
            break
        yield [{"text": line.strip()} for line in batch]


# Traceback (UnicodeDecodeError)
Traceback (most recent call last):
File "/app/server/views.py", line 121, in post
documents = self.csv_to_documents(project, file)
File "/app/server/views.py", line 77, in csv_to_documents
maybe_header = next(reader)
File "/virtualenvs/doccano-HEgudFLz/bin/../lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

# Fixed code
def parse(self, file):
    file = EncodedIO(file)
    file = io.TextIOWrapper(file, encoding=file.encoding)
    while True:
        batch = list(itertools.islice(file, settings.IMPORT_BATCH_SIZE))
        if not batch:
            break
        yield [{"text": line.strip()} for line in batch]
# Buggy code
def parse(self, file):
    file = io.TextIOWrapper(file, encoding="utf-8")
    reader = csv.reader(file)
    yield from ExcelParser.parse_excel_csv_reader(reader)


# Traceback (UnicodeDecodeError)
Traceback (most recent call last):
File "/app/server/views.py", line 121, in post
documents = self.csv_to_documents(project, file)
File "/app/server/views.py", line 77, in csv_to_documents
maybe_header = next(reader)
File "/virtualenvs/doccano-HEgudFLz/bin/../lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

# Fixed code
def parse(self, file):
    file = EncodedIO(file)
    file = io.TextIOWrapper(file, encoding=file.encoding)
    reader = csv.reader(file)
    yield from ExcelParser.parse_excel_csv_reader(reader)
# Buggy code
def parse(self, file):
    file = io.TextIOWrapper(file, encoding="utf-8")
    data = []
    for i, line in enumerate(file, start=1):
        if len(data) >= settings.IMPORT_BATCH_SIZE:
            yield data
            data = []
        try:
            j = json.loads(line)
            j["meta"] = json.dumps(j.get("meta", {}))
            data.append(j)
        except json.decoder.JSONDecodeError:
            raise FileParseException(line_num=i, line=line)
    if data:
        yield data


# Traceback (UnicodeDecodeError)
Traceback (most recent call last):
File "/app/server/views.py", line 121, in post
documents = self.csv_to_documents(project, file)
File "/app/server/views.py", line 77, in csv_to_documents
maybe_header = next(reader)
File "/virtualenvs/doccano-HEgudFLz/bin/../lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

# Fixed code
def parse(self, file):
    file = EncodedIO(file)
    file = io.TextIOWrapper(file, encoding=file.encoding)
    data = []
    for i, line in enumerate(file, start=1):
        if len(data) >= settings.IMPORT_BATCH_SIZE:
            yield data
            data = []
        try:
            j = json.loads(line)
            j["meta"] = json.dumps(j.get("meta", {}))
            data.append(j)
        except json.decoder.JSONDecodeError:
            raise FileParseException(line_num=i, line=line)
    if data:
        yield data
# Buggy code
def authenticate(self):
    data = self._api_call("authenticate", {"auth": self.auth}, schema=_login_schema)
    self.auth = data["auth"]
    self.cache.set("auth", data["auth"], expires_at=data["expires"])
    return data


# Traceback (streamlink.plugin.crunchyroll.CrunchyrollAPIError)
Traceback (most recent call last):
File "runpy.py", line 193, in _run_module_as_main
File "runpy.py", line 85, in _run_code
File "C:\Users\kg\AppData\Local\Streamlink\bin\streamlink.exe\__main__.py", line 18, in <module>
File "C:\Users\kg\AppData\Local\Streamlink\pkgs\streamlink_cli\main.py", line 1024, in main
handle_url()
File "C:\Users\kg\AppData\Local\Streamlink\pkgs\streamlink_cli\main.py", line 585, in handle_url
streams = fetch_streams(plugin)
File "C:\Users\kg\AppData\Local\Streamlink\pkgs\streamlink_cli\main.py", line 465, in fetch_streams
sorting_excludes=args.stream_sorting_excludes)
File "C:\Users\kg\AppData\Local\Streamlink\pkgs\streamlink\plugin\plugin.py", line 317, in streams
ostreams = self._get_streams()
File "C:\Users\kg\AppData\Local\Streamlink\pkgs\streamlink\plugins\crunchyroll.py", line 306, in _get_streams
api = self._create_api()
File "C:\Users\kg\AppData\Local\Streamlink\pkgs\streamlink\plugins\crunchyroll.py", line 369, in _create_api
login = api.authenticate()
File "C:\Users\kg\AppData\Local\Streamlink\pkgs\streamlink\plugins\crunchyroll.py", line 217, in authenticate
data = self._api_call("authenticate", {"auth": self.auth}, schema=_login_schema)
File "C:\Users\kg\AppData\Local\Streamlink\pkgs\streamlink\plugins\crunchyroll.py", line 173, in _api_call
raise CrunchyrollAPIError(err_msg, err_code)
streamlink.plugin.crunchyroll.CrunchyrollAPIError: User could not be found.

# Fixed code
def authenticate(self):
    try:
        data = self._api_call("authenticate", {"auth": self.auth}, schema=_login_schema)
    except CrunchyrollAPIError:
        self.auth = None
        self.cache.set("auth", None, expires_at=0)
        log.warning("Saved credentials have expired")
        return

    log.debug("Credentials expire at: {}".format(data["expires"]))
    self.cache.set("auth", self.auth, expires_at=data["expires"])
    return data
# Buggy code
def _open_call(self):
    args = self._create_arguments()
    if is_win32:
        fargs = args
    else:
        fargs = subprocess.list2cmdline(args)
    log.debug("Calling: {0}".format(maybe_decode(fargs)))
    subprocess.call(args, stdout=self.stdout, stderr=self.stderr)


# Traceback (UnicodeDecodeError)
OS: macOS 10.14.2
Python: 2.7.14
Streamlink: 1.1.1
Requests(2.21.0), Socks(1.6.7), Websocket(0.47.0)
Found matching plugin twitch for URL twitch.tv/quickybaby
Plugin specific arguments:
--twitch-oauth-token=******** (oauth_token)
--twitch-disable-hosting=True (disable_hosting)
--twitch-disable-ads=True (disable_ads)
Getting live HLS streams for quickybaby
Attempting to authenticate using OAuth token
Successfully logged in as DELETE
[utils.l10n][debug] Language code: en_US
Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60, 1080p60 (best)
Opening stream: 1080p60 (hls)
Starting player: /Applications/mpv.app/Contents/MacOS/mpv
Traceback (most recent call last):
File "/usr/local/bin/streamlink", line 11, in <module>
load_entry_point('streamlink==1.1.1', 'console_scripts', 'streamlink')()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 1033, in main
handle_url()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 594, in handle_url
handle_stream(plugin, streams, stream_name)
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 437, in handle_stream
success = output_stream_passthrough(plugin, stream)
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 262, in output_stream_passthrough
output.open()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 24, in open
self._open()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 219, in _open
self._open_call()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 234, in _open_call
log.debug(u"Calling: {0}".format(fargs))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 141: ordinal not in range(128)

# Fixed code
def _open_call(self):
    args = self._create_arguments()
    if is_win32:
        fargs = args
    else:
        fargs = subprocess.list2cmdline(args)
    log.debug("Calling: {0}".format(fargs))

    subprocess.call(
        maybe_encode(args, get_filesystem_encoding()),
        stdout=self.stdout,
        stderr=self.stderr,
    )
# Buggy code
def maybe_encode(text, encoding="utf8"):
    if is_py2:
        return text.encode(encoding)
    else:
        return text


# Traceback (UnicodeDecodeError)
OS: macOS 10.14.2
Python: 2.7.14
Streamlink: 1.1.1
Requests(2.21.0), Socks(1.6.7), Websocket(0.47.0)
Found matching plugin twitch for URL twitch.tv/quickybaby
Plugin specific arguments:
--twitch-oauth-token=******** (oauth_token)
--twitch-disable-hosting=True (disable_hosting)
--twitch-disable-ads=True (disable_ads)
Getting live HLS streams for quickybaby
Attempting to authenticate using OAuth token
Successfully logged in as DELETE
[utils.l10n][debug] Language code: en_US
Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60, 1080p60 (best)
Opening stream: 1080p60 (hls)
Starting player: /Applications/mpv.app/Contents/MacOS/mpv
Traceback (most recent call last):
File "/usr/local/bin/streamlink", line 11, in <module>
load_entry_point('streamlink==1.1.1', 'console_scripts', 'streamlink')()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 1033, in main
handle_url()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 594, in handle_url
handle_stream(plugin, streams, stream_name)
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 437, in handle_stream
success = output_stream_passthrough(plugin, stream)
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 262, in output_stream_passthrough
output.open()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 24, in open
self._open()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 219, in _open
self._open_call()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 234, in _open_call
log.debug(u"Calling: {0}".format(fargs))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 141: ordinal not in range(128)

# Fixed code
def maybe_encode(text, encoding="utf8"):
    if is_py2:
        if isinstance(text, unicode):
            return text.encode(encoding)
        else:
            return text
    else:
        return text
# Buggy code
def _open_call(self):
    args = self._create_arguments()
    if is_win32:
        fargs = args
    else:
        fargs = subprocess.list2cmdline(args)
    log.debug("Calling: {0}".format(fargs))
    subprocess.call(args, stdout=self.stdout, stderr=self.stderr)


# Traceback (UnicodeDecodeError)
OS: macOS 10.14.2
Python: 2.7.14
Streamlink: 1.1.1
Requests(2.21.0), Socks(1.6.7), Websocket(0.47.0)
Found matching plugin twitch for URL twitch.tv/quickybaby
Plugin specific arguments:
--twitch-oauth-token=******** (oauth_token)
--twitch-disable-hosting=True (disable_hosting)
--twitch-disable-ads=True (disable_ads)
Getting live HLS streams for quickybaby
Attempting to authenticate using OAuth token
Successfully logged in as DELETE
[utils.l10n][debug] Language code: en_US
Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60, 1080p60 (best)
Opening stream: 1080p60 (hls)
Starting player: /Applications/mpv.app/Contents/MacOS/mpv
Traceback (most recent call last):
File "/usr/local/bin/streamlink", line 11, in <module>
load_entry_point('streamlink==1.1.1', 'console_scripts', 'streamlink')()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 1033, in main
handle_url()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 594, in handle_url
handle_stream(plugin, streams, stream_name)
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 437, in handle_stream
success = output_stream_passthrough(plugin, stream)
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/main.py", line 262, in output_stream_passthrough
output.open()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 24, in open
self._open()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 219, in _open
self._open_call()
File "/usr/local/lib/python2.7/site-packages/streamlink-1.1.1-py2.7.egg/streamlink_cli/output.py", line 234, in _open_call
log.debug(u"Calling: {0}".format(fargs))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 141: ordinal not in range(128)

# Fixed code
def _open_call(self):
    args = self._create_arguments()
    if is_win32:
        fargs = args
    else:
        fargs = subprocess.list2cmdline(args)
    log.debug("Calling: {0}".format(maybe_decode(fargs)))
    subprocess.call(args, stdout=self.stdout, stderr=self.stderr)
# Buggy code
def close(self, client_only=False):
    if self.conn:
        self.conn.close()

    if not client_only:
        try:
            self.socket.shutdown(2)
        except OSError:
            pass
        self.socket.close()


# Traceback (socket.error)
[cli][info] Closing currently open stream...
Traceback (most recent call last):
File "/usr/local/bin/streamlink", line 11, in <module>
load_entry_point('streamlink==0.6.0', 'console_scripts', 'streamlink')()
File "/usr/local/lib/python2.7/site-packages/streamlink_cli/main.py", line 1027, in main
handle_url()
File "/usr/local/lib/python2.7/site-packages/streamlink_cli/main.py", line 502, in handle_url
handle_stream(plugin, streams, stream_name)
File "/usr/local/lib/python2.7/site-packages/streamlink_cli/main.py", line 380, in handle_stream
return output_stream_http(plugin, streams)
File "/usr/local/lib/python2.7/site-packages/streamlink_cli/main.py", line 192, in output_stream_http
server.close()
File "/usr/local/lib/python2.7/site-packages/streamlink_cli/utils/http_server.py", line 116, in close
self.socket.shutdown(2)
File "/usr/local/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 57] Socket is not connected

# Fixed code
def close(self, client_only=False):
    if self.conn:
        self.conn.close()

    if not client_only:
        try:
            self.socket.shutdown(2)
        except (OSError, socket.error):
            pass
        self.socket.close()
# Buggy code
def close(self, client_only=False):
    if self.conn:
        self.conn.close()

    if not client_only:
        self.socket.shutdown(2)
        self.socket.close()


# Traceback (OSError)
[cli][info] Player closed
[cli][info] Stream ended
[cli][info] Closing currently open stream...
Traceback (most recent call last):
File "d:\Program Files (x86)\Streamlink\bin\streamlink-script.py", line 12, in
<module>
main()
File "d:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\main.py", line 952
, in main
handle_url()
File "d:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\main.py", line 499
, in handle_url
handle_stream(plugin, streams, stream_name)
File "d:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\main.py", line 381
, in handle_stream
success = output_stream(stream)
File "d:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\main.py", line 270
, in output_stream
read_stream(stream_fd, output, prebuffer)
File "contextlib.py", line 159, in __exit__
File "d:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\output.py", line 2
8, in close
self._close()
File "d:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\output.py", line 1
58, in _close
self.http.close()
File "d:\Program Files (x86)\Streamlink\pkgs\streamlink_cli\utils\http_server.
py", line 115, in close
self.socket.shutdown(2)
OSError: [WinError 10057] A request to send or receive data was disallowed becau
se the socket is not connected and (when sending on a datagram socket using a se
ndto call) no address was supplied

# Fixed code
def close(self, client_only=False):
    if self.conn:
        self.conn.close()

    if not client_only:
        try:
            self.socket.shutdown(2)
        except OSError:
            pass
        self.socket.close()
# Buggy code
def set_attr_from_xmp_tag(self, attr, xmp_tags, tags, cast=None):
    v = self.get_xmp_tag(xmp_tags, tags)
    if v is not None:
        if cast is None:
            setattr(self, attr, v)
        else:
            setattr(self, attr, cast(v))


# Traceback (ValueError)
[INFO]    Loading 4 images
Traceback (most recent call last):
File "/code/opendm/photo.py", line 225, in parse_exif_values
], float)
File "/code/opendm/photo.py", line 256, in set_attr_from_xmp_tag
setattr(self, attr, cast(v))
ValueError: could not convert string to float: '610/1000'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/code/run.py", line 68, in <module>
app.execute()
File "/code/stages/odm_app.py", line 95, in execute
self.first_stage.run()
File "/code/opendm/types.py", line 337, in run
self.process(self.args, outputs)
File "/code/stages/dataset.py", line 109, in process
p = types.ODM_Photo(f)
File "/code/opendm/photo.py", line 70, in __init__
self.parse_exif_values(path_file)
File "/code/opendm/photo.py", line 236, in parse_exif_values
log.ODM_WARNING("Cannot read XMP tags for %s: %s" % (_path_file, e.message))
AttributeError: 'ValueError' object has no attribute 'message'

# Fixed code
def set_attr_from_xmp_tag(self, attr, xmp_tags, tags, cast=None):
    v = self.get_xmp_tag(xmp_tags, tags)
    if v is not None:
        if cast is None:
            setattr(self, attr, v)
        else:
            # Handle fractions
            if (cast == float or cast == int) and "/" in v:
                v = self.try_parse_fraction(v)
            setattr(self, attr, cast(v))
# Buggy code
def extendMarkdown(self, md):
    """Insert AbbrPreprocessor before ReferencePreprocessor."""
    md.preprocessors.register(AbbrPreprocessor(md), "abbr", 12)


# Traceback (IndexError)
Traceback (most recent call last):
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/test_tools.py", line 117, in test
output = markdown(input, **kwargs)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 391, in markdown
return md.convert(text)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 268, in convert
root = self.parser.parseDocument(self.lines).getroot()
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 92, in parseDocument
self.parseChunk(self.root, '\n'.join(lines))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 107, in parseChunk
self.parseBlocks(parent, text.split('\n\n'))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 125, in parseBlocks
if processor.run(parent, blocks) is not False:
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 127, in run
block = self._process_nests(element, block)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 95, in _process_nests
block[nest_index[-1][1]:], True)                      # nest
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 101, in run
tag = self._tag_data[self.parser.blockprocessors.tag_counter]
IndexError: list index out of range

# Fixed code
def extendMarkdown(self, md):
    """Insert AbbrPreprocessor before ReferencePreprocessor."""
    md.parser.blockprocessors.register(AbbrPreprocessor(md.parser), "abbr", 16)
# Buggy code
def run(self, lines):
    """
    Find and remove all Abbreviation references from the text.
    Each reference is set as a new AbbrPattern in the markdown instance.

    """
    new_text = []
    for line in lines:
        m = ABBR_REF_RE.match(line)
        if m:
            abbr = m.group("abbr").strip()
            title = m.group("title").strip()
            self.md.inlinePatterns.register(
                AbbrInlineProcessor(self._generate_pattern(abbr), title),
                "abbr-%s" % abbr,
                2,
            )
            # Preserve the line to prevent raw HTML indexing issue.
            # https://github.com/Python-Markdown/markdown/issues/584
            new_text.append("")
        else:
            new_text.append(line)
    return new_text


# Traceback (IndexError)
Traceback (most recent call last):
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/test_tools.py", line 117, in test
output = markdown(input, **kwargs)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 391, in markdown
return md.convert(text)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 268, in convert
root = self.parser.parseDocument(self.lines).getroot()
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 92, in parseDocument
self.parseChunk(self.root, '\n'.join(lines))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 107, in parseChunk
self.parseBlocks(parent, text.split('\n\n'))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 125, in parseBlocks
if processor.run(parent, blocks) is not False:
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 127, in run
block = self._process_nests(element, block)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 95, in _process_nests
block[nest_index[-1][1]:], True)                      # nest
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 101, in run
tag = self._tag_data[self.parser.blockprocessors.tag_counter]
IndexError: list index out of range

# Fixed code
def run(self, parent, blocks):
    """
    Find and remove all Abbreviation references from the text.
    Each reference is set as a new AbbrPattern in the markdown instance.

    """
    block = blocks.pop(0)
    m = self.RE.search(block)
    if m:
        abbr = m.group("abbr").strip()
        title = m.group("title").strip()
        self.parser.md.inlinePatterns.register(
            AbbrInlineProcessor(self._generate_pattern(abbr), title),
            "abbr-%s" % abbr,
            2,
        )
        if block[m.end() :].strip():
            # Add any content after match back to blocks as separate block
            blocks.insert(0, block[m.end() :].lstrip("\n"))
        if block[: m.start()].strip():
            # Add any content before match back to blocks as separate block
            blocks.insert(0, block[: m.start()].rstrip("\n"))
        return True
    # No match. Restore block.
    blocks.insert(0, block)
    return False
# Buggy code
def detab(line):
    match = TABBED_RE.match(line)
    if match:
        return match.group(4)


# Traceback (IndexError)
Traceback (most recent call last):
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/test_tools.py", line 117, in test
output = markdown(input, **kwargs)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 391, in markdown
return md.convert(text)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 268, in convert
root = self.parser.parseDocument(self.lines).getroot()
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 92, in parseDocument
self.parseChunk(self.root, '\n'.join(lines))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 107, in parseChunk
self.parseBlocks(parent, text.split('\n\n'))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 125, in parseBlocks
if processor.run(parent, blocks) is not False:
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 127, in run
block = self._process_nests(element, block)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 95, in _process_nests
block[nest_index[-1][1]:], True)                      # nest
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 101, in run
tag = self._tag_data[self.parser.blockprocessors.tag_counter]
IndexError: list index out of range

# Fixed code
def detab(self, block):
    """Remove one level of indent from a block.

    Preserve lazily indented blocks by only removing indent from indented lines.
    """
    lines = block.split("\n")
    for i, line in enumerate(lines):
        if line.startswith(" " * 4):
            lines[i] = line[4:]
    return "\n".join(lines)
# Buggy code
def extendMarkdown(self, md):
    """Register extension instances."""

    # Turn on processing of markdown text within raw html
    md.preprocessors["html_block"].markdown_in_raw = True
    md.parser.blockprocessors.register(
        MarkdownInHtmlProcessor(md.parser), "markdown_block", 105
    )
    md.parser.blockprocessors.tag_counter = -1
    md.parser.blockprocessors.contain_span_tags = re.compile(
        r"^(p|h[1-6]|li|dd|dt|td|th|legend|address)$", re.IGNORECASE
    )


# Traceback (IndexError)
Traceback (most recent call last):
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/test_tools.py", line 117, in test
output = markdown(input, **kwargs)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 391, in markdown
return md.convert(text)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 268, in convert
root = self.parser.parseDocument(self.lines).getroot()
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 92, in parseDocument
self.parseChunk(self.root, '\n'.join(lines))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 107, in parseChunk
self.parseBlocks(parent, text.split('\n\n'))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 125, in parseBlocks
if processor.run(parent, blocks) is not False:
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 127, in run
block = self._process_nests(element, block)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 95, in _process_nests
block[nest_index[-1][1]:], True)                      # nest
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 101, in run
tag = self._tag_data[self.parser.blockprocessors.tag_counter]
IndexError: list index out of range

# Fixed code
def extendMarkdown(self, md):
    """Register extension instances."""

    # Replace raw HTML preprocessor
    md.preprocessors.register(HtmlBlockPreprocessor(md), "html_block", 20)
    # Add blockprocessor which handles the placeholders for etree elements
    md.parser.blockprocessors.register(
        MarkdownInHtmlProcessor(md.parser), "markdown_block", 105
    )
# Buggy code
def run(self, text):
    """Iterate over html stash and restore html."""
    replacements = OrderedDict()
    for i in range(self.md.htmlStash.html_counter):
        html = self.md.htmlStash.rawHtmlBlocks[i]
        if self.isblocklevel(html):
            replacements["<p>%s</p>" % (self.md.htmlStash.get_placeholder(i))] = (
                html + "\n"
            )
        replacements[self.md.htmlStash.get_placeholder(i)] = html

    if replacements:
        pattern = re.compile("|".join(re.escape(k) for k in replacements))
        processed_text = pattern.sub(lambda m: replacements[m.group(0)], text)
    else:
        return text

    if processed_text == text:
        return processed_text
    else:
        return self.run(processed_text)


# Traceback (IndexError)
Traceback (most recent call last):
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/test_tools.py", line 117, in test
output = markdown(input, **kwargs)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 391, in markdown
return md.convert(text)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 268, in convert
root = self.parser.parseDocument(self.lines).getroot()
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 92, in parseDocument
self.parseChunk(self.root, '\n'.join(lines))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 107, in parseChunk
self.parseBlocks(parent, text.split('\n\n'))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 125, in parseBlocks
if processor.run(parent, blocks) is not False:
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 127, in run
block = self._process_nests(element, block)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 95, in _process_nests
block[nest_index[-1][1]:], True)                      # nest
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 101, in run
tag = self._tag_data[self.parser.blockprocessors.tag_counter]
IndexError: list index out of range

# Fixed code
def run(self, text):
    """Iterate over html stash and restore html."""
    replacements = OrderedDict()
    for i in range(self.md.htmlStash.html_counter):
        html = self.md.htmlStash.rawHtmlBlocks[i]
        if self.isblocklevel(html):
            replacements["<p>{}</p>".format(self.md.htmlStash.get_placeholder(i))] = (
                html
            )
        replacements[self.md.htmlStash.get_placeholder(i)] = html

    if replacements:
        pattern = re.compile("|".join(re.escape(k) for k in replacements))
        processed_text = pattern.sub(lambda m: replacements[m.group(0)], text)
    else:
        return text

    if processed_text == text:
        return processed_text
    else:
        return self.run(processed_text)
# Buggy code
def build_preprocessors(md, **kwargs):
    """Build the default set of preprocessors used by Markdown."""
    preprocessors = util.Registry()
    preprocessors.register(NormalizeWhitespace(md), "normalize_whitespace", 30)
    preprocessors.register(HtmlBlockPreprocessor(md), "html_block", 20)
    preprocessors.register(ReferencePreprocessor(md), "reference", 10)
    return preprocessors


# Traceback (IndexError)
Traceback (most recent call last):
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/test_tools.py", line 117, in test
output = markdown(input, **kwargs)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 391, in markdown
return md.convert(text)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 268, in convert
root = self.parser.parseDocument(self.lines).getroot()
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 92, in parseDocument
self.parseChunk(self.root, '\n'.join(lines))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 107, in parseChunk
self.parseBlocks(parent, text.split('\n\n'))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 125, in parseBlocks
if processor.run(parent, blocks) is not False:
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 127, in run
block = self._process_nests(element, block)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 95, in _process_nests
block[nest_index[-1][1]:], True)                      # nest
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 101, in run
tag = self._tag_data[self.parser.blockprocessors.tag_counter]
IndexError: list index out of range

# Fixed code
def build_preprocessors(md, **kwargs):
    """Build the default set of preprocessors used by Markdown."""
    preprocessors = util.Registry()
    preprocessors.register(NormalizeWhitespace(md), "normalize_whitespace", 30)
    preprocessors.register(HtmlBlockPreprocessor(md), "html_block", 20)
    return preprocessors