gurudesh/pytracebugs huggingface dataset:
# Buggy code
def is_archived(self, owner, repo):
    logging.info("Querying committers count\n")
    url = f"https://api.github.com/repos/{owner}/{repo}"

    r = requests.get(url, headers=self.headers)
    self.update_gh_rate_limit(r)

    data = self.get_repo_data(url, r)

    if "archived" in data:
        if data["archived"]:
            if "updated_at" in data:
                return data["updated_at"]
            return "Date not available"
        return False

    return False


# Traceback (TypeError)
INFO:root:Worker ran into an error for task: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}}

INFO:root:Printing traceback...

INFO:root:Traceback (most recent call last):
File "/mnt/md0/github/augur-census/workers/worker_base.py", line 189, in collect
model_method(message, repo_id)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 149, in repo_info_model
forked = self.is_forked(owner, repo)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 232, in is_forked
data = self.get_repo_data(self, url, r)
TypeError: get_repo_data() takes 3 positional arguments but 4 were given

INFO:root:This task inserted 0 tuples before failure.

INFO:root:Notifying broker and logging task failure in database...

INFO:werkzeug:127.0.0.1 - - [31/May/2020 18:48:58] "GET /AUGWOP/heartbeat HTTP/1.1" 200 -
INFO:root:Recorded job error in the history table for: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}, 'worker_id': 'com.augurlabs.core.repo_info_worker.50700'}

INFO:root:Updated job process for model: repo_info

# Fixed code
def is_archived(self, owner, repo):
    self.logger.info("Querying committers count\n")
    url = f"https://api.github.com/repos/{owner}/{repo}"

    r = requests.get(url, headers=self.headers)
    self.update_gh_rate_limit(r)

    data = self.get_repo_data(url, r)

    if "archived" in data:
        if data["archived"]:
            if "updated_at" in data:
                return data["updated_at"]
            return "Date not available"
        return False

    return False
# Buggy code
def LogError(self, err):
    self.logs.append("Error dumping ACPI table.")
    self.logs.append("%r: %s" % (err, err))
    self.logs.extend(self.chipsec_log.getvalue().split("\n"))
    self.SendReply(chipsec_types.DumpACPITableResponse(logs=self.logs))


# Traceback (ArtifactNotRegisteredError)
Traceback (most recent call last): File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 644, in RunStateMethod responses=responses) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flows/general/discovery.py", line 153, in Platform next_state="ProcessKnowledgeBase") File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 784, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 940, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 927, in StartFlow flow_obj.Start() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 143, in Start first_flows = self.GetFirstFlowsForCollection() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 407, in GetFirstFlowsForCollection artifact_registry.REGISTRY.GetArtifact(artifact_name) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact_registry.py", line 304, in GetArtifact "directory." % name) ArtifactNotRegisteredError: Artifact WMIProfileUsersHomeDir missing from registry. You may need to sync the artifact repo by running make in the artifact directory.

# Fixed code
def LogError(self, err):
    self.logs.append("Error dumping ACPI table.")
    self.logs.append("%r: %s" % (err, err))
    self.logs.extend(self.chipsec_log.getvalue().splitlines())
    self.SendReply(chipsec_types.DumpACPITableResponse(logs=self.logs))
# Buggy code
def Handle(self, args, token=None):
    try:
        flow_obj = aff4.FACTORY.Open(
            args.operation_id, aff4_type="Interrogate", token=token
        )

        complete = not flow_obj.GetRunner().IsRunning()
    except aff4.InstantiationError:
        raise InterrogateOperationNotFoundError(
            "Operation with id %s not found" % args.operation_id
        )

    result = ApiGetInterrogateOperationStateResult()
    if complete:
        result.state = ApiGetInterrogateOperationStateResult.State.FINISHED
    else:
        result.state = ApiGetInterrogateOperationStateResult.State.RUNNING

    return result


# Traceback (ArtifactNotRegisteredError)
Traceback (most recent call last): File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 644, in RunStateMethod responses=responses) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flows/general/discovery.py", line 153, in Platform next_state="ProcessKnowledgeBase") File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 784, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 940, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 927, in StartFlow flow_obj.Start() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 143, in Start first_flows = self.GetFirstFlowsForCollection() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 407, in GetFirstFlowsForCollection artifact_registry.REGISTRY.GetArtifact(artifact_name) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact_registry.py", line 304, in GetArtifact "directory." % name) ArtifactNotRegisteredError: Artifact WMIProfileUsersHomeDir missing from registry. You may need to sync the artifact repo by running make in the artifact directory.

# Fixed code
def Handle(self, args, token=None):
    try:
        flow_obj = aff4.FACTORY.Open(
            args.operation_id, aff4_type=discovery.Interrogate, token=token
        )

        complete = not flow_obj.GetRunner().IsRunning()
    except aff4.InstantiationError:
        raise InterrogateOperationNotFoundError(
            "Operation with id %s not found" % args.operation_id
        )

    result = ApiGetInterrogateOperationStateResult()
    if complete:
        result.state = ApiGetInterrogateOperationStateResult.State.FINISHED
    else:
        result.state = ApiGetInterrogateOperationStateResult.State.RUNNING

    return result
# Buggy code
def _ReadExactly(self, n):
    ret = ""
    left = n
    while left:
        data = self.sock.recv(left)
        if data == "":
            raise IOError("Expected %d bytes, got EOF after %d" % (n, len(ret)))
        ret += data
        left = n - len(ret)
    return ret


# Traceback (ArtifactNotRegisteredError)
Traceback (most recent call last): File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 644, in RunStateMethod responses=responses) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flows/general/discovery.py", line 153, in Platform next_state="ProcessKnowledgeBase") File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 784, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 940, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 927, in StartFlow flow_obj.Start() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 143, in Start first_flows = self.GetFirstFlowsForCollection() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 407, in GetFirstFlowsForCollection artifact_registry.REGISTRY.GetArtifact(artifact_name) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact_registry.py", line 304, in GetArtifact "directory." % name) ArtifactNotRegisteredError: Artifact WMIProfileUsersHomeDir missing from registry. You may need to sync the artifact repo by running make in the artifact directory.

# Fixed code
def _ReadExactly(self, n):
    ret = ""
    left = n
    while left:
        data = self.sock.recv(left)
        if not data:
            raise IOError("Expected %d bytes, got EOF after %d" % (n, len(ret)))
        ret += data
        left = n - len(ret)
    return ret
# Buggy code
def Parse(self, stat, knowledge_base):
    """Parse the key currentcontrolset output."""
    value = stat.registry_data.GetValue()
    if not value:
        raise parsers.ParseError("Invalid value for key %s" % stat.pathspec.path)
    value = artifact_utils.ExpandWindowsEnvironmentVariables(value, knowledge_base)
    if value:
        yield rdfvalue.RDFString(value)


# Traceback (ArtifactNotRegisteredError)
Traceback (most recent call last): File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 644, in RunStateMethod responses=responses) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flows/general/discovery.py", line 153, in Platform next_state="ProcessKnowledgeBase") File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 784, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 940, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 927, in StartFlow flow_obj.Start() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 143, in Start first_flows = self.GetFirstFlowsForCollection() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 407, in GetFirstFlowsForCollection artifact_registry.REGISTRY.GetArtifact(artifact_name) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact_registry.py", line 304, in GetArtifact "directory." % name) ArtifactNotRegisteredError: Artifact WMIProfileUsersHomeDir missing from registry. You may need to sync the artifact repo by running make in the artifact directory.

# Fixed code
def Parse(self, stat, knowledge_base):
    """Expand any variables in the value."""
    value = stat.registry_data.GetValue()
    if not value:
        raise parsers.ParseError("Invalid value for key %s" % stat.pathspec.path)
    value = artifact_utils.ExpandWindowsEnvironmentVariables(value, knowledge_base)
    if value:
        yield rdfvalue.RDFString(value)
# Buggy code
def Parse(self, stat, _):
    """Parse the key currentcontrolset output."""
    value = stat.registry_data.GetValue()
    if not value:
        raise parsers.ParseError("Invalid value for key %s" % stat.pathspec.path)

    systemdrive = value[0:2]
    if re.match(r"^[A-Za-z]:$", systemdrive):
        yield rdfvalue.RDFString(systemdrive)
    else:
        raise parsers.ParseError("Bad drive letter for key %s" % stat.pathspec.path)


# Traceback (ArtifactNotRegisteredError)
Traceback (most recent call last): File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 644, in RunStateMethod responses=responses) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flows/general/discovery.py", line 153, in Platform next_state="ProcessKnowledgeBase") File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 784, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 940, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 927, in StartFlow flow_obj.Start() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 143, in Start first_flows = self.GetFirstFlowsForCollection() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 407, in GetFirstFlowsForCollection artifact_registry.REGISTRY.GetArtifact(artifact_name) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact_registry.py", line 304, in GetArtifact "directory." % name) ArtifactNotRegisteredError: Artifact WMIProfileUsersHomeDir missing from registry. You may need to sync the artifact repo by running make in the artifact directory.

# Fixed code
def Parse(self, stat, _):
    """Parse the key currentcontrolset output."""
    # SystemDriveEnvironmentVariable produces a statentry,
    # WindowsEnvironmentVariableSystemDrive produces a string
    if isinstance(stat, rdf_client.StatEntry):
        value = stat.registry_data.GetValue()
    elif isinstance(stat, rdfvalue.RDFString):
        value = stat
    if not value:
        raise parsers.ParseError("Invalid value for key %s" % stat.pathspec.path)

    systemdrive = value[0:2]
    if re.match(r"^[A-Za-z]:$", systemdrive):
        yield rdfvalue.RDFString(systemdrive)
    else:
        raise parsers.ParseError("Bad drive letter for key %s" % stat.pathspec.path)
# Buggy code
def MakeCoreSdist(self):
    os.chdir(args.grr_src)
    subprocess.check_call(
        [
            self.PYTHON_BIN64,
            "setup.py",
            "sdist",
            "--dist-dir=%s" % self.BUILDDIR,
            "--no-make-docs",
            "--no-sync-artifacts",
        ]
    )
    return glob.glob(os.path.join(self.BUILDDIR, "grr-response-core-*.zip")).pop()


# Traceback (ArtifactNotRegisteredError)
Traceback (most recent call last): File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 644, in RunStateMethod responses=responses) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flows/general/discovery.py", line 153, in Platform next_state="ProcessKnowledgeBase") File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 784, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow_runner.py", line 940, in CallFlow **kwargs) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 927, in StartFlow flow_obj.Start() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/flow.py", line 346, in Decorated res = f(*args[:f.func_code.co_argcount]) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 143, in Start first_flows = self.GetFirstFlowsForCollection() File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact.py", line 407, in GetFirstFlowsForCollection artifact_registry.REGISTRY.GetArtifact(artifact_name) File "/usr/share/grr-server/local/lib/python2.7/site-packages/grr/lib/artifact_registry.py", line 304, in GetArtifact "directory." % name) ArtifactNotRegisteredError: Artifact WMIProfileUsersHomeDir missing from registry. You may need to sync the artifact repo by running make in the artifact directory.

# Fixed code
def MakeCoreSdist(self):
    os.chdir(args.grr_src)
    subprocess.check_call(
        [
            self.PYTHON_BIN64,
            "setup.py",
            "sdist",
            "--dist-dir=%s" % self.BUILDDIR,
            "--no-make-docs",
            "--no-make-ui-files",
            "--no-sync-artifacts",
        ]
    )
    return glob.glob(os.path.join(self.BUILDDIR, "grr-response-core-*.zip")).pop()
# Buggy code
def pool(self):
    """Create thread pool on first request
    avoids instantiating unused threadpool for blocking clients.
    """
    if self._pool is None:
        self._pool = ThreadPool(self.pool_threads)
    return self._pool


# Traceback (CError)
done



^CException ignored in: <bound method ApiClient.__del__ of <kubernetes.client.api_client.ApiClient object at 0x7f8f9ba67c50>>
Traceback (most recent call last):
File "/home/fabian/Envs/test/lib/python3.6/site-packages/kubernetes/client/api_client.py", line 81, in __del__
self._pool.join()
File "/usr/lib64/python3.6/multiprocessing/pool.py", line 546, in join
self._worker_handler.join()
File "/usr/lib64/python3.6/threading.py", line 1056, in join
self._wait_for_tstate_lock()
File "/usr/lib64/python3.6/threading.py", line 1072, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt
^CError in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib64/python3.6/multiprocessing/util.py", line 262, in _run_finalizers
finalizer()
File "/usr/lib64/python3.6/multiprocessing/util.py", line 186, in __call__
res = self._callback(*self._args, **self._kwargs)
File "/usr/lib64/python3.6/multiprocessing/pool.py", line 582, in _terminate_pool
worker_handler.join()
File "/usr/lib64/python3.6/threading.py", line 1056, in join
self._wait_for_tstate_lock()
File "/usr/lib64/python3.6/threading.py", line 1072, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt

# Fixed code
def pool(self):
    """Create thread pool on first request
    avoids instantiating unused threadpool for blocking clients.
    """
    if self._pool is None:
        atexit.register(self.close)
        self._pool = ThreadPool(self.pool_threads)
    return self._pool
# Buggy code
def copy(self):
    # By using serialization we are absolutely sure all refs are new
    xml = self.tostring()
    try:
        return ParseTree().fromstring(xml)
    except:
        print(">>>", xml, "<<<")
        raise


# Traceback (ParseError)
ERROR: Exception in signal handler for process on <zim.templates.Template object at 0x7f2a60595650>
Traceback (most recent call last):
File "/mnt/projects/zim-desktop-wiki/zim/signals.py", line 338, in emit
r = handler(self, *args)
File "/mnt/projects/zim-desktop-wiki/zim/templates/__init__.py", line 186, in do_process
processor.process(output, context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 81, in process
self.__call__(output, self.main, context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 130, in __call__
self._loop(output, element, context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 169, in _loop
self.__call__(output, element, context) # recurs
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 111, in __call__
value = expr(context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/expression.py", line 124, in __call__
value = getattr(value, p)
File "/mnt/projects/zim-desktop-wiki/zim/export/template.py", line 488, in title
return self.heading or self.basename
File "/mnt/projects/zim-desktop-wiki/zim/export/template.py", line 431, in heading
head, body = self._split_head()
File "/mnt/projects/zim-desktop-wiki/zim/export/template.py", line 462, in _split_head
tree = self._tree.copy()
File "/mnt/projects/zim-desktop-wiki/zim/formats/__init__.py", line 330, in copy
return ParseTree().fromstring(xml)
File "/mnt/projects/zim-desktop-wiki/zim/formats/__init__.py", line 307, in fromstring
parser.feed(string)
ParseError: not well-formed (invalid token): line 35, column 5
ERROR: Could not read: /path/to/Notebook/Page/SubPage/attachment.txt

# Fixed code
def copy(self):
    builder = ParseTreeBuilder(_parsetree_roundtrip=True)
    self.visit(builder)
    return builder.get_parsetree()
# Buggy code
def start(self, tag, attrib=None):
    self._b.start(tag, attrib)
    self.stack.append(tag)
    if tag in BLOCK_LEVEL:
        self._last_char = None


# Traceback (ParseError)
ERROR: Exception in signal handler for process on <zim.templates.Template object at 0x7f2a60595650>
Traceback (most recent call last):
File "/mnt/projects/zim-desktop-wiki/zim/signals.py", line 338, in emit
r = handler(self, *args)
File "/mnt/projects/zim-desktop-wiki/zim/templates/__init__.py", line 186, in do_process
processor.process(output, context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 81, in process
self.__call__(output, self.main, context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 130, in __call__
self._loop(output, element, context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 169, in _loop
self.__call__(output, element, context) # recurs
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 111, in __call__
value = expr(context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/expression.py", line 124, in __call__
value = getattr(value, p)
File "/mnt/projects/zim-desktop-wiki/zim/export/template.py", line 488, in title
return self.heading or self.basename
File "/mnt/projects/zim-desktop-wiki/zim/export/template.py", line 431, in heading
head, body = self._split_head()
File "/mnt/projects/zim-desktop-wiki/zim/export/template.py", line 462, in _split_head
tree = self._tree.copy()
File "/mnt/projects/zim-desktop-wiki/zim/formats/__init__.py", line 330, in copy
return ParseTree().fromstring(xml)
File "/mnt/projects/zim-desktop-wiki/zim/formats/__init__.py", line 307, in fromstring
parser.feed(string)
ParseError: not well-formed (invalid token): line 35, column 5
ERROR: Could not read: /path/to/Notebook/Page/SubPage/attachment.txt

# Fixed code
def start(self, tag, attrib=None):
    attrib = attrib.copy() if attrib is not None else None
    self._b.start(tag, attrib)
    self.stack.append(tag)
    if tag in BLOCK_LEVEL:
        self._last_char = None
# Buggy code
def append(self, tag, attrib=None, text=None):
    if tag in BLOCK_LEVEL:
        if text and not text.endswith("\n"):
            text += "\n"

    # FIXME hack for backward compat
    if text and tag in (HEADING, LISTITEM):
        text = text.strip("\n")

    self._b.start(tag, attrib)
    if text:
        self._b.data(text)
    self._b.end(tag)

    # FIXME hack for backward compat
    if tag == HEADING:
        self._b.data("\n")

    self._last_char = None


# Traceback (ParseError)
ERROR: Exception in signal handler for process on <zim.templates.Template object at 0x7f2a60595650>
Traceback (most recent call last):
File "/mnt/projects/zim-desktop-wiki/zim/signals.py", line 338, in emit
r = handler(self, *args)
File "/mnt/projects/zim-desktop-wiki/zim/templates/__init__.py", line 186, in do_process
processor.process(output, context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 81, in process
self.__call__(output, self.main, context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 130, in __call__
self._loop(output, element, context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 169, in _loop
self.__call__(output, element, context) # recurs
File "/mnt/projects/zim-desktop-wiki/zim/templates/processor.py", line 111, in __call__
value = expr(context)
File "/mnt/projects/zim-desktop-wiki/zim/templates/expression.py", line 124, in __call__
value = getattr(value, p)
File "/mnt/projects/zim-desktop-wiki/zim/export/template.py", line 488, in title
return self.heading or self.basename
File "/mnt/projects/zim-desktop-wiki/zim/export/template.py", line 431, in heading
head, body = self._split_head()
File "/mnt/projects/zim-desktop-wiki/zim/export/template.py", line 462, in _split_head
tree = self._tree.copy()
File "/mnt/projects/zim-desktop-wiki/zim/formats/__init__.py", line 330, in copy
return ParseTree().fromstring(xml)
File "/mnt/projects/zim-desktop-wiki/zim/formats/__init__.py", line 307, in fromstring
parser.feed(string)
ParseError: not well-formed (invalid token): line 35, column 5
ERROR: Could not read: /path/to/Notebook/Page/SubPage/attachment.txt

# Fixed code
def append(self, tag, attrib=None, text=None):
    attrib = attrib.copy() if attrib is not None else None
    if tag in BLOCK_LEVEL:
        if text and not text.endswith("\n"):
            text += "\n"

    # FIXME hack for backward compat
    if text and tag in (HEADING, LISTITEM):
        text = text.strip("\n")

    self._b.start(tag, attrib)
    if text:
        self._b.data(text)
    self._b.end(tag)

    # FIXME hack for backward compat
    if tag == HEADING and not self._parsetree_roundtrip:
        self._b.data("\n")

    self._last_char = None
# Buggy code
def get_candidates_and_features_page_num(self, page_num):
    elems = self.elems[page_num]
    #  font_stat = self.font_stats[page_num]
    #  lines_bboxes = self.get_candidates_lines(page_num, elems)
    alignments_bboxes, alignment_features = self.get_candidates_alignments(
        page_num, elems
    )
    # print "Page Num: ", page_num, "Line bboxes: ", len(lines_bboxes), ", Alignment bboxes: ", len(alignments_bboxes)
    # alignment_features += get_alignment_features(lines_bboxes, elems, font_stat)
    boxes = alignments_bboxes  # + lines_bboxes
    if len(boxes) == 0:
        log.info("No boxes were found on page {}.".format(page_num))
        return [], []
    lines_features = get_lines_features(boxes, elems)
    features = np.concatenate(
        (np.array(alignment_features), np.array(lines_features)), axis=1
    )
    return boxes, features


# Traceback (ValueError)
Digitized PDF detected, building tree structure
float division by zero
float division by zero
float division by zero
(89.33853599999992, 89.33853599999992, 50)
Traceback (most recent call last):
File "chh_test.py", line 10, in <module>
pdftotree.parse(filename, htmlpath, model_path=None, favor_figures=False, visualize=True)
File "/home/chhenning/repos/pdftotree/pdftotree/core.py", line 57, in parse
pdf_tree = extractor.get_tree_structure(model, favor_figures)
File "/home/chhenning/repos/pdftotree/pdftotree/TreeExtract.py", line 195, in get_tree_structure
favor_figures)
File "/home/chhenning/repos/pdftotree/pdftotree/pdf/pdf_parsers.py", line 615, in parse_tree_structure
figures_page = get_figures(mentions, elems.layout.bbox, page_num, boxes_figures, page_width, page_height)
File "/home/chhenning/repos/pdftotree/pdftotree/pdf/pdf_parsers.py", line 945, in get_figures
page_stat = Node(boxes)
File "/home/chhenning/repos/pdftotree/pdftotree/pdf/node.py", line 44, in __init__
self.set_bbox(bound_elems(elems))
File "/home/chhenning/repos/pdftotree/pdftotree/pdf/vector_utils.py", line 101, in bound_elems
group_x0 = min(map(lambda l:l.x0,elems))
ValueError: min() arg is an empty sequence

# Fixed code
def get_candidates_and_features_page_num(self, page_num):
    elems = self.elems[page_num]
    #  font_stat = self.font_stats[page_num]
    #  lines_bboxes = self.get_candidates_lines(page_num, elems)
    alignments_bboxes, alignment_features = self.get_candidates_alignments(
        page_num, elems
    )
    # print "Page Num: ", page_num, "Line bboxes: ", len(lines_bboxes), ", Alignment bboxes: ", len(alignments_bboxes)
    # alignment_features += get_alignment_features(lines_bboxes, elems, font_stat)
    boxes = alignments_bboxes
    if len(boxes) == 0:
        log.info("No boxes were found on page {}.".format(page_num))
        return [], []

    lines_features = get_lines_features(boxes, elems)
    features = np.concatenate(
        (np.array(alignment_features), np.array(lines_features)), axis=1
    )
    return boxes, features
# Buggy code
def unescapeHTML(s):
    if s is None:
        return None
    assert type(s) == compat_str

    return re.sub(r"&([^;]+;)", lambda m: _htmlentity_transform(m.group(1)), s)


# Traceback (ExtractorError)
youtube-dl -gvv https://www.cda.pl/video/9443700b
[debug] System config: [u'--prefer-free-formats']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-gvv', u'https://www.cda.pl/video/9443700b']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.08.13
[debug] Python version 2.7.13 - Linux-4.11.12-200.fc25.x86_64-x86_64-with-fedora-25-Gurgle
[debug] exe versions: ffmpeg 3.1.9, ffprobe 3.1.9
[debug] Proxy map: {}
WARNING: [CDA] default player_data: Failed to parse JSON Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
WARNING: [CDA] 480p player_data: Failed to parse JSON Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
WARNING: [CDA] 720p player_data: Failed to parse JSON Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
WARNING: [CDA] 1080p player_data: Failed to parse JSON Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
ERROR: No video formats found; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 776, in extract_info
ie_result = ie.extract(url)
File "/usr/bin/youtube-dl/youtube_dl/extractor/common.py", line 433, in extract
ie_result = self._real_extract(url)
File "/usr/bin/youtube-dl/youtube_dl/extractor/cda.py", line 180, in _real_extract
self._sort_formats(formats)
File "/usr/bin/youtube-dl/youtube_dl/extractor/common.py", line 1057, in _sort_formats
raise ExtractorError('No video formats found')
ExtractorError: No video formats found; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

# Fixed code
def unescapeHTML(s):
    if s is None:
        return None
    assert type(s) == compat_str

    return re.sub(r"&([^&;]+;)", lambda m: _htmlentity_transform(m.group(1)), s)
# Buggy code
async def sendfile(self, writer: asyncio.StreamWriter) -> int:
    """
    Read and send the file to the writer and return the number of bytes sent
    """

    if not self.is_readable():
        raise OSError("blob files cannot be read")
    with self.reader_context() as handle:
        try:
            return await self.loop.sendfile(
                writer.transport, handle, count=self.get_length()
            )
        except (
            ConnectionResetError,
            BrokenPipeError,
            RuntimeError,
            OSError,
            AttributeError,
        ):
            return -1


# Traceback (AttributeError)
2019-08-01 18:18:06,916 INFO     lbry.stream.reflector.client:119: Sent reflector blob e5828b7e
2019-08-01 18:18:29,221 INFO     lbry.stream.reflector.client:119: Sent reflector blob 867d1a2c
2019-08-01 18:18:51,545 INFO     lbry.stream.reflector.client:119: Sent reflector blob 6e365367
2019-08-01 18:18:58,400 INFO     lbry.extras.daemon.Daemon:2330: publishing: name: xxxx params: {'title': 'xxxx', 'description': 'xxxxxx', 'bid': '0.10000000', 'languages': ['en'], 'tags': ['xxxxx'], 'thumbnail_url': 'https://spee.ch/8/xxxxxxxxx', 'license': 'All rights reserved   Published With Permission', 'release_time': 1564696220, 'channel_id': 'xxxxxxxxxxxx', 'fee_currency': 'LBC', 'fee_amount': '1.00000000', 'file_path': 'C:\\Users\\David T\\Desktop\\GMCZ0549_VID_1280x720x1500kbs_HCVC549.mp4'}
2019-08-01 18:19:22,348 ERROR    lbry.extras.daemon.Daemon:586: error handling api request
Traceback (most recent call last):
File "lbry\extras\daemon\Daemon.py", line 580, in _process_rpc_call
File "lbry\extras\daemon\Daemon.py", line 2342, in jsonrpc_publish
File "lbry\extras\daemon\Daemon.py", line 2659, in jsonrpc_stream_update
File "lbry\stream\stream_manager.py", line 232, in delete_stream
AttributeError: 'NoneType' object has no attribute 'stop_tasks'
2019-08-01 18:19:37,886 INFO     lbry.stream.reflector.client:119: Sent reflector blob f5b10e7b
2019-08-01 18:20:00,717 INFO     lbry.stream.reflector.client:119: Sent reflector blob d5ffe375

# Fixed code
async def sendfile(self, writer: asyncio.StreamWriter) -> int:
    """
    Read and send the file to the writer and return the number of bytes sent
    """

    if not self.is_readable():
        raise OSError("blob files cannot be read")
    with self.reader_context() as handle:
        try:
            return await self.loop.sendfile(
                writer.transport, handle, count=self.get_length()
            )
        except (
            ConnectionError,
            BrokenPipeError,
            RuntimeError,
            OSError,
            AttributeError,
        ):
            return -1
# Buggy code
def stop(self):
    if self.resume_saving_task and not self.resume_saving_task.done():
        self.resume_saving_task.cancel()
    if self.re_reflect_task and not self.re_reflect_task.done():
        self.re_reflect_task.cancel()
    while self.streams:
        _, stream = self.streams.popitem()
        stream.stop_tasks()
    while self.update_stream_finished_futs:
        self.update_stream_finished_futs.pop().cancel()
    while self.running_reflector_uploads:
        self.running_reflector_uploads.pop().cancel()
    self.started.clear()
    log.info("finished stopping the stream manager")


# Traceback (AttributeError)
2019-08-01 18:18:06,916 INFO     lbry.stream.reflector.client:119: Sent reflector blob e5828b7e
2019-08-01 18:18:29,221 INFO     lbry.stream.reflector.client:119: Sent reflector blob 867d1a2c
2019-08-01 18:18:51,545 INFO     lbry.stream.reflector.client:119: Sent reflector blob 6e365367
2019-08-01 18:18:58,400 INFO     lbry.extras.daemon.Daemon:2330: publishing: name: xxxx params: {'title': 'xxxx', 'description': 'xxxxxx', 'bid': '0.10000000', 'languages': ['en'], 'tags': ['xxxxx'], 'thumbnail_url': 'https://spee.ch/8/xxxxxxxxx', 'license': 'All rights reserved   Published With Permission', 'release_time': 1564696220, 'channel_id': 'xxxxxxxxxxxx', 'fee_currency': 'LBC', 'fee_amount': '1.00000000', 'file_path': 'C:\\Users\\David T\\Desktop\\GMCZ0549_VID_1280x720x1500kbs_HCVC549.mp4'}
2019-08-01 18:19:22,348 ERROR    lbry.extras.daemon.Daemon:586: error handling api request
Traceback (most recent call last):
File "lbry\extras\daemon\Daemon.py", line 580, in _process_rpc_call
File "lbry\extras\daemon\Daemon.py", line 2342, in jsonrpc_publish
File "lbry\extras\daemon\Daemon.py", line 2659, in jsonrpc_stream_update
File "lbry\stream\stream_manager.py", line 232, in delete_stream
AttributeError: 'NoneType' object has no attribute 'stop_tasks'
2019-08-01 18:19:37,886 INFO     lbry.stream.reflector.client:119: Sent reflector blob f5b10e7b
2019-08-01 18:20:00,717 INFO     lbry.stream.reflector.client:119: Sent reflector blob d5ffe375

# Fixed code
def stop(self):
    if self.resume_saving_task and not self.resume_saving_task.done():
        self.resume_saving_task.cancel()
    if self.re_reflect_task and not self.re_reflect_task.done():
        self.re_reflect_task.cancel()
    while self.streams:
        _, stream = self.streams.popitem()
        stream.stop_tasks()
    while self.update_stream_finished_futs:
        self.update_stream_finished_futs.pop().cancel()
    while self.running_reflector_uploads:
        _, t = self.running_reflector_uploads.popitem()
        t.cancel()
    self.started.clear()
    log.info("finished stopping the stream manager")
# Buggy code
async def create_stream(
    self,
    file_path: str,
    key: Optional[bytes] = None,
    iv_generator: Optional[typing.Generator[bytes, None, None]] = None,
) -> ManagedStream:
    stream = await ManagedStream.create(
        self.loop, self.config, self.blob_manager, file_path, key, iv_generator
    )
    self.streams[stream.sd_hash] = stream
    self.storage.content_claim_callbacks[stream.stream_hash] = (
        lambda: self._update_content_claim(stream)
    )
    if self.config.reflect_streams and self.config.reflector_servers:
        host, port = random.choice(self.config.reflector_servers)
        task = self.loop.create_task(stream.upload_to_reflector(host, port))
        self.running_reflector_uploads.append(task)
        task.add_done_callback(
            lambda _: None
            if task not in self.running_reflector_uploads
            else self.running_reflector_uploads.remove(task)
        )
    return stream


# Traceback (AttributeError)
2019-08-01 18:18:06,916 INFO     lbry.stream.reflector.client:119: Sent reflector blob e5828b7e
2019-08-01 18:18:29,221 INFO     lbry.stream.reflector.client:119: Sent reflector blob 867d1a2c
2019-08-01 18:18:51,545 INFO     lbry.stream.reflector.client:119: Sent reflector blob 6e365367
2019-08-01 18:18:58,400 INFO     lbry.extras.daemon.Daemon:2330: publishing: name: xxxx params: {'title': 'xxxx', 'description': 'xxxxxx', 'bid': '0.10000000', 'languages': ['en'], 'tags': ['xxxxx'], 'thumbnail_url': 'https://spee.ch/8/xxxxxxxxx', 'license': 'All rights reserved   Published With Permission', 'release_time': 1564696220, 'channel_id': 'xxxxxxxxxxxx', 'fee_currency': 'LBC', 'fee_amount': '1.00000000', 'file_path': 'C:\\Users\\David T\\Desktop\\GMCZ0549_VID_1280x720x1500kbs_HCVC549.mp4'}
2019-08-01 18:19:22,348 ERROR    lbry.extras.daemon.Daemon:586: error handling api request
Traceback (most recent call last):
File "lbry\extras\daemon\Daemon.py", line 580, in _process_rpc_call
File "lbry\extras\daemon\Daemon.py", line 2342, in jsonrpc_publish
File "lbry\extras\daemon\Daemon.py", line 2659, in jsonrpc_stream_update
File "lbry\stream\stream_manager.py", line 232, in delete_stream
AttributeError: 'NoneType' object has no attribute 'stop_tasks'
2019-08-01 18:19:37,886 INFO     lbry.stream.reflector.client:119: Sent reflector blob f5b10e7b
2019-08-01 18:20:00,717 INFO     lbry.stream.reflector.client:119: Sent reflector blob d5ffe375

# Fixed code
async def create_stream(
    self,
    file_path: str,
    key: Optional[bytes] = None,
    iv_generator: Optional[typing.Generator[bytes, None, None]] = None,
) -> ManagedStream:
    stream = await ManagedStream.create(
        self.loop, self.config, self.blob_manager, file_path, key, iv_generator
    )
    self.streams[stream.sd_hash] = stream
    self.storage.content_claim_callbacks[stream.stream_hash] = (
        lambda: self._update_content_claim(stream)
    )
    if self.config.reflect_streams and self.config.reflector_servers:
        self.reflect_stream(stream)
    return stream
# Buggy code
async def delete_stream(
    self, stream: ManagedStream, delete_file: Optional[bool] = False
):
    stream.stop_tasks()
    if stream.sd_hash in self.streams:
        del self.streams[stream.sd_hash]
    blob_hashes = [stream.sd_hash] + [b.blob_hash for b in stream.descriptor.blobs[:-1]]
    await self.blob_manager.delete_blobs(blob_hashes, delete_from_db=False)
    await self.storage.delete_stream(stream.descriptor)
    if delete_file and stream.output_file_exists:
        os.remove(stream.full_path)


# Traceback (AttributeError)
2019-08-01 18:18:06,916 INFO     lbry.stream.reflector.client:119: Sent reflector blob e5828b7e
2019-08-01 18:18:29,221 INFO     lbry.stream.reflector.client:119: Sent reflector blob 867d1a2c
2019-08-01 18:18:51,545 INFO     lbry.stream.reflector.client:119: Sent reflector blob 6e365367
2019-08-01 18:18:58,400 INFO     lbry.extras.daemon.Daemon:2330: publishing: name: xxxx params: {'title': 'xxxx', 'description': 'xxxxxx', 'bid': '0.10000000', 'languages': ['en'], 'tags': ['xxxxx'], 'thumbnail_url': 'https://spee.ch/8/xxxxxxxxx', 'license': 'All rights reserved   Published With Permission', 'release_time': 1564696220, 'channel_id': 'xxxxxxxxxxxx', 'fee_currency': 'LBC', 'fee_amount': '1.00000000', 'file_path': 'C:\\Users\\David T\\Desktop\\GMCZ0549_VID_1280x720x1500kbs_HCVC549.mp4'}
2019-08-01 18:19:22,348 ERROR    lbry.extras.daemon.Daemon:586: error handling api request
Traceback (most recent call last):
File "lbry\extras\daemon\Daemon.py", line 580, in _process_rpc_call
File "lbry\extras\daemon\Daemon.py", line 2342, in jsonrpc_publish
File "lbry\extras\daemon\Daemon.py", line 2659, in jsonrpc_stream_update
File "lbry\stream\stream_manager.py", line 232, in delete_stream
AttributeError: 'NoneType' object has no attribute 'stop_tasks'
2019-08-01 18:19:37,886 INFO     lbry.stream.reflector.client:119: Sent reflector blob f5b10e7b
2019-08-01 18:20:00,717 INFO     lbry.stream.reflector.client:119: Sent reflector blob d5ffe375

# Fixed code
async def delete_stream(
    self, stream: ManagedStream, delete_file: Optional[bool] = False
):
    if stream.sd_hash in self.running_reflector_uploads:
        self.running_reflector_uploads[stream.sd_hash].cancel()
    stream.stop_tasks()
    if stream.sd_hash in self.streams:
        del self.streams[stream.sd_hash]
    blob_hashes = [stream.sd_hash] + [b.blob_hash for b in stream.descriptor.blobs[:-1]]
    await self.blob_manager.delete_blobs(blob_hashes, delete_from_db=False)
    await self.storage.delete_stream(stream.descriptor)
    if delete_file and stream.output_file_exists:
        os.remove(stream.full_path)
# Buggy code
def is_comment_signed_by_channel(comment: dict, channel: Output):
    try:
        pieces = [
            comment["signing_ts"].encode(),
            channel.claim_hash,
            comment["comment"].encode(),
        ]
        return Output.is_signature_valid(
            get_encoded_signature(comment["signature"]),
            sha256(b"".join(pieces)),
            channel.claim.channel.public_key_bytes,
        )
    except KeyError:
        pass
    return False


# Traceback (AttributeError)
(lbry-venv) C:\Users\thoma\Documents\lbry>lbrynet comment list --claim_id=20f54f401de44b9b5ba866e60286144995824468{
"code": -32500,
"data": [
"Traceback (most recent call last):",
"  File \"c:\\users\\thoma\\documents\\lbry\\lbry\\lbry\\extras\\daemon\\Daemon.py\", line 579, in _process_rpc_call",
"    result = await result",
"  File \"c:\\users\\thoma\\documents\\lbry\\lbry\\lbry\\extras\\daemon\\Daemon.py\", line 3429, in jsonrpc_comment_list",
"    cmnt['is_channel_signature_valid'] = is_comment_signed_by_channel(cmnt, channel)",
"  File \"c:\\users\\thoma\\documents\\lbry\\lbry\\lbry\\extras\\daemon\\comment_client.py\", line 25, in is_comment_signed_by_channel",
"    channel.claim_hash,",
"AttributeError: 'dict' object has no attribute 'claim_hash'",
""
],
"message": "'dict' object has no attribute 'claim_hash'"```

# Fixed code
def is_comment_signed_by_channel(comment: dict, channel: Output):
    if type(channel) is Output:
        try:
            pieces = [
                comment["signing_ts"].encode(),
                channel.claim_hash,
                comment["comment"].encode(),
            ]
            return Output.is_signature_valid(
                get_encoded_signature(comment["signature"]),
                sha256(b"".join(pieces)),
                channel.claim.channel.public_key_bytes,
            )
        except KeyError:
            pass
    return False
# Buggy code
def _fetch_tx(self, txid):
    async def __fetch_parse(txid):
        return self.transaction_class(
            unhexlify(await self.network.get_transaction(txid))
        )

    return asyncio.ensure_future(__fetch_parse(txid))


# Traceback (concurrent.futures._base.CancelledError)
2019-05-16 15:14:35,679 INFO     lbrynet.dht.blob_announcer:51: announced 5 blobs
2019-05-16 15:15:04,419 INFO     torba.client.baseledger:133: lbc_mainnet: added BlockHeightEvent(height=568534, change=1) header blocks, final height 568534
2019-05-16 15:15:21,629 INFO     lbrynet.blob_exchange.client:137: downloaded 4af012f8 from 18.213.255.15:5567
2019-05-16 15:15:21,652 INFO     lbrynet.stream.managed_stream:358: write blob 8/76
2019-05-16 15:15:28,815 INFO     torba.client.baseledger:133: lbc_mainnet: added BlockHeightEvent(height=568535, change=1) header blocks, final height 568535
2019-05-16 15:16:24,383 ERROR    lbrynet.wallet.resolve:42:
Traceback (most recent call last):
File "lbrynet/wallet/resolve.py", line 38, in resolve
File "lbrynet/wallet/resolve.py", line 67, in _handle_resolutions
File "lbrynet/wallet/resolve.py", line 109, in _handle_resolve_uri_response
File "lbrynet/wallet/resolve.py", line 172, in parse_and_validate_claim_result
concurrent.futures._base.CancelledError
2019-05-16 15:16:24,391 WARNING  lbrynet.extras.daemon.Daemon:914: Error downloading mp3: Failed to resolve "mp3" within the timeout
2019-05-16 15:16:31,259 ERROR    lbrynet.wallet.resolve:42:
Traceback (most recent call last):
File "lbrynet/wallet/resolve.py", line 38, in resolve
File "lbrynet/wallet/resolve.py", line 67, in _handle_resolutions
File "lbrynet/wallet/resolve.py", line 109, in _handle_resolve_uri_response
File "lbrynet/wallet/resolve.py", line 172, in parse_and_validate_claim_result
concurrent.futures._base.CancelledError
2019-05-16 15:16:31,267 WARNING  lbrynet.extras.daemon.Daemon:914: Error downloading mp3: 'str' object has no attribute 'get'
2019-05-16 15:16:39,715 ERROR    lbrynet.wallet.resolve:42:
Traceback (most recent call last):
File "lbrynet/wallet/resolve.py", line 38, in resolve
File "lbrynet/wallet/resolve.py", line 67, in _handle_resolutions
File "lbrynet/wallet/resolve.py", line 109, in _handle_resolve_uri_response
File "lbrynet/wallet/resolve.py", line 172, in parse_and_validate_claim_result
concurrent.futures._base.CancelledError
2019-05-16 15:16:39,728 WARNING  lbrynet.extras.daemon.Daemon:914: Error downloading mp3: 'str' object has no attribute 'get'
2019-05-16 15:18:36,193 INFO     torba.client.baseledger:133: lbc_mainnet: added BlockHeightEvent(height=568536, change=1) header blocks, final height 568536

# Fixed code
async def _fetch_tx(self, txid):
    return self.transaction_class(unhexlify(await self.network.get_transaction(txid)))
# Buggy code
async def save_max_gap(self):
    gap = await self.get_max_gap()
    self.receiving.gap = max(20, gap["max_receiving_gap"] + 1)
    self.change.gap = max(6, gap["max_change_gap"] + 1)
    self.wallet.save()


# Traceback (AttributeError)
Traceback (most recent call last):
File "c:\users\thoma\documents\lbry\lbrynet\extras\daemon\Component.py", line 55, in _setup
result = await self.start()
File "c:\users\thoma\documents\lbry\lbrynet\extras\daemon\Components.py", line 268, in start
await self.wallet_manager.start()
File "c:\users\thoma\documents\lbry\lbry-venv\lib\site-packages\torba\client\basemanager.py", line 73, in start
l.start() for l in self.ledgers.values()
File "c:\users\thoma\documents\lbry\lbrynet\wallet\ledger.py", line 69, in start
await asyncio.gather(*(a.save_max_gap() for a in self.accounts))
File "c:\users\thoma\documents\lbry\lbrynet\wallet\account.py", line 171, in save_max_gap
self.receiving.gap = max(20, gap['max_receiving_gap'] + 1)
AttributeError: 'SingleKey' object has no attribute 'gap'

# Fixed code
async def save_max_gap(self):
    if issubclass(self.address_generator, HierarchicalDeterministic):
        gap = await self.get_max_gap()
        self.receiving.gap = max(20, gap["max_receiving_gap"] + 1)
        self.change.gap = max(6, gap["max_change_gap"] + 1)
        self.wallet.save()