gurudesh/pytracebugs huggingface dataset:
# Buggy code
def _save(self):
    dname = os.path.dirname(self._path)
    with tempfile.NamedTemporaryFile(dir=dname, delete=False) as outf:
        tname = outf.name
        json.dump(self._local.data, outf, sort_keys=True, indent=2)
    shutil.move(tname, self._path)


# Traceback (TypeError)
Traceback (most recent call last):
File "/home/kwpolska/virtualenvs/nikola-py3/lib/python3.5/site-packages/doit/doit_cmd.py", line 168, in run
return command.parse_execute(args)
File "/home/kwpolska/virtualenvs/nikola-py3/lib/python3.5/site-packages/doit/cmd_base.py", line 122, in parse_execute
return self.execute(params, args)
File "/home/kwpolska/git/nikola/nikola/plugin_categories.py", line 124, in execute
return self._execute(options, args)
File "/home/kwpolska/git/nikola/nikola/plugins/command/deploy.py", line 135, in _execute
self.site.state.set('last_deploy', new_deploy.isoformat())
File "/home/kwpolska/git/nikola/nikola/state.py", line 64, in set
self._save()
File "/home/kwpolska/git/nikola/nikola/state.py", line 82, in _save
json.dump(self._local.data, outf, sort_keys=True, indent=2)
File "/usr/lib64/python3.5/json/__init__.py", line 179, in dump
fp.write(chunk)
File "/home/kwpolska/virtualenvs/nikola-py3/lib/python3.5/tempfile.py", line 483, in func_wrapper
return func(*args, **kwargs)
TypeError: a bytes-like object is required, not 'str'

# Fixed code
def _save(self):
    dname = os.path.dirname(self._path)
    with tempfile.NamedTemporaryFile(dir=dname, delete=False) as outf:
        # TODO replace with encoding='utf-8' and mode 'w+' in v8
        tname = outf.name
        data = json.dumps(self._local.data, sort_keys=True, indent=2)
        try:
            outf.write(data)
        except TypeError:
            outf.write(data.encode("utf-8"))
    shutil.move(tname, self._path)
# Buggy code
def guess_locale_from_lang_posix(lang):
    """Guess a locale, basing on POSIX system language."""
    # compatibility v6.0.4
    if is_valid_locale(str(lang)):
        locale_n = str(lang)
    else:
        # this works in Travis when locale support set by Travis suggestion
        locale_n = str((locale.normalize(lang).split(".")[0]) + ".utf8")
    if not is_valid_locale(locale_n):
        # http://thread.gmane.org/gmane.comp.web.nikola/337/focus=343
        locale_n = str((locale.normalize(lang).split(".")[0]))
    if not is_valid_locale(locale_n):
        locale_n = None
    return locale_n


# Traceback (UnicodeDecodeError)
[2015-10-07T18:13:19Z] WARNING: Nikola: Could not guess locale for language de, using locale C
[2015-10-07T18:13:20Z] ERROR: yapsy: Unable to import plugin: /usr/home/wayne/nikola/blog.cle.ar.it/plugins/ping/ping
Traceback (most recent call last):
File "/usr/home/wayne/nikola/lib/python3.5/site-packages/yapsy/PluginManager.py", line 488, in loadPlugins
candidate_module = imp.load_module(plugin_module_name,plugin_file,candidate_filepath+".py",("py","r",imp.PY_SOURCE))
File "/usr/local/lib/python3.5/imp.py", line 234, in load_module
return load_source(name, filename, file)
File "/usr/local/lib/python3.5/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 658, in exec_module
File "<frozen importlib._bootstrap_external>", line 763, in get_code
File "/usr/local/lib/python3.5/imp.py", line 156, in get_data
return file.read()
File "/usr/local/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 37: ordinal not in range(128)

# Fixed code
def guess_locale_from_lang_posix(lang):
    """Guess a locale, basing on POSIX system language."""
    # compatibility v6.0.4
    if is_valid_locale(str(lang)):
        locale_n = str(lang)
    else:
        # this works in Travis when locale support set by Travis suggestion
        locale_n = str((locale.normalize(lang).split(".")[0]) + ".UTF-8")
    if not is_valid_locale(locale_n):
        # http://thread.gmane.org/gmane.comp.web.nikola/337/focus=343
        locale_n = str((locale.normalize(lang).split(".")[0]))
    if not is_valid_locale(locale_n):
        locale_n = None
    return locale_n
# Buggy code
def write_header_line(fd, header_field, header_content):
    """Write comment header line."""
    if header_content is None:
        return
    header_content = str(header_content).replace("\n", " ")
    line = ".. " + header_field + ": " + header_content + "\n"
    fd.write(line.encode("utf8"))


# Traceback (UnicodeEncodeError)
Traceback (most recent call last):
File "/path/lib/python2.7/site-packages/doit/doit_cmd.py", line 168, in run
return command.parse_execute(args)
File "/path/lib/python2.7/site-packages/doit/cmd_base.py", line 122, in parse_execute
return self.execute(params, args)
File "/path/lib/python2.7/site-packages/nikola/plugin_categories.py", line 127, in execute
return self._execute(options, args)
File "/path/lib/python2.7/site-packages/nikola/plugins/command/import_wordpress.py", line 325, in _execute
self.import_posts(channel)
File "/path/lib/python2.7/site-packages/nikola/plugins/command/import_wordpress.py", line 982, in import_posts
self.process_item_if_post_or_page(item)
File "/path/lib/python2.7/site-packages/nikola/plugins/command/import_wordpress.py", line 963, in process_item_if_post_or_page
out_folder_slug = self.import_postpage_item(item, wordpress_namespace, 'posts', attachments)
File "/path/lib/python2.7/site-packages/nikola/plugins/command/import_wordpress.py", line 916, in import_postpage_item
self._write_comment(os.path.join(self.output_folder, out_folder, comment_filename), comment)
File "/path/lib/python2.7/site-packages/nikola/plugins/command/import_wordpress.py", line 722, in _write_comment
write_header_line(fd, "author", comment["author"])
File "/path/lib/python2.7/site-packages/nikola/plugins/command/import_wordpress.py", line 714, in write_header_line
header_content = str(header_content).replace('\n', ' ')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 2: ordinal not in range(128)

# Fixed code
def write_header_line(fd, header_field, header_content):
    """Write comment header line."""
    if header_content is None:
        return
    header_content = unicode_str(header_content).replace("\n", " ")
    line = ".. " + header_field + ": " + header_content + "\n"
    fd.write(line.encode("utf8"))
# Buggy code
def add(our_key, wp_key, is_int=False, ignore_zero=False):
    if wp_key in image_meta:
        value = image_meta[wp_key]
        if is_int:
            value = int(value)
            if ignore_zero and value == 0:
                return
        else:
            value = value.decode("utf-8")  # assume UTF-8
            if value == "":  # skip empty values
                return
        dst_meta[our_key] = value


# Traceback (ValueError)
[2015-07-30T10:35:36Z] INFO: import_wordpress: Downloading http://alexkerney.com/wp-content/uploads/2010/10/Sheepscot-1.jpg => new_site/files/wp-content/uploads/2010/10/Sheepscot-1.jpg
[2015-07-30T10:35:36Z] INFO: requests.packages.urllib3.connectionpool: Starting new HTTP connection (1): alexkerney.com
Traceback (most recent call last):
File "/Users/kerneya/virtualenvs/regular-nikola/lib/python3.4/site-packages/doit/doit_cmd.py", line 165, in run
return command.parse_execute(args)
File "/Users/kerneya/virtualenvs/regular-nikola/lib/python3.4/site-packages/doit/cmd_base.py", line 122, in parse_execute
return self.execute(params, args)
File "/Users/kerneya/virtualenvs/regular-nikola/lib/python3.4/site-packages/nikola/plugin_categories.py", line 127, in execute
return self._execute(options, args)
File "/Users/kerneya/virtualenvs/regular-nikola/lib/python3.4/site-packages/nikola/plugins/command/import_wordpress.py", line 325, in _execute
self.import_posts(channel)
File "/Users/kerneya/virtualenvs/regular-nikola/lib/python3.4/site-packages/nikola/plugins/command/import_wordpress.py", line 968, in import_posts
self.process_item_if_attachment(item)
File "/Users/kerneya/virtualenvs/regular-nikola/lib/python3.4/site-packages/nikola/plugins/command/import_wordpress.py", line 931, in process_item_if_attachment
data = self.import_attachment(item, wordpress_namespace)
File "/Users/kerneya/virtualenvs/regular-nikola/lib/python3.4/site-packages/nikola/plugins/command/import_wordpress.py", line 533, in import_attachment
add('shutter_speed', b'shutter_speed', is_int=True, ignore_zero=True)
File "/Users/kerneya/virtualenvs/regular-nikola/lib/python3.4/site-packages/nikola/plugins/command/import_wordpress.py", line 516, in add
value = int(value)
ValueError: invalid literal for int() with base 10: b'0.0025'

# Fixed code
def add(our_key, wp_key, is_int=False, ignore_zero=False, is_float=False):
    if wp_key in image_meta:
        value = image_meta[wp_key]
        if is_int:
            value = int(value)
            if ignore_zero and value == 0:
                return
        elif is_float:
            value = float(value)
            if ignore_zero and value == 0:
                return
        else:
            value = value.decode("utf-8")  # assume UTF-8
            if value == "":  # skip empty values
                return
        dst_meta[our_key] = value
# Buggy code
def serve_static(self, environ, start_response):
    """Trivial static file server."""
    uri = wsgiref.util.request_uri(environ)
    p_uri = urlparse(uri)
    f_path = os.path.join(self.site.config["OUTPUT_FOLDER"], *p_uri.path.split("/"))
    mimetype = mimetypes.guess_type(uri)[0] or "text/html"

    if os.path.isdir(f_path):
        f_path = os.path.join(f_path, self.site.config["INDEX_FILE"])

    if p_uri.path == "/robots.txt":
        start_response("200 OK", [("Content-type", "text/plain")])
        return """User-Agent: *\nDisallow: /\n"""
    elif os.path.isfile(f_path):
        with open(f_path, "rb") as fd:
            start_response("200 OK", [("Content-type", mimetype)])
            return self.inject_js(mimetype, fd.read())
    elif p_uri.path == "/livereload.js":
        with open(LRJS_PATH) as fd:
            start_response("200 OK", [("Content-type", mimetype)])
            return self.inject_js(mimetype, fd.read())
    start_response("404 ERR", [])
    return self.inject_js("text/html", ERROR_N.format(404).format(uri))


# Traceback (AssertionError)
Traceback (most recent call last):
File "/usr/lib/python3.4/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/user/.local/lib/python3.4/site-packages/nikola/plugins/command/auto/__init__.py", line 188, in __call__
return parent.serve_static(environ, start_response)
File "/home/user/.local/lib/python3.4/site-packages/nikola/plugins/command/auto/__init__.py", line 243, in serve_static
start_response(b'200 OK', [(b'Content-type', mimetype)])
File "/usr/lib/python3.4/wsgiref/handlers.py", line 226, in start_response
self.headers = self.headers_class(headers)
File "/usr/lib/python3.4/wsgiref/headers.py", line 38, in __init__
self._convert_string_type(k)
File "/usr/lib/python3.4/wsgiref/headers.py", line 46, in _convert_string_type
" of type str (got {0})".format(repr(value)))
AssertionError: Header names/values must be of type str (got b'Content-type')

# Fixed code
def serve_static(self, environ, start_response):
    """Trivial static file server."""
    uri = wsgiref.util.request_uri(environ)
    p_uri = urlparse(uri)
    f_path = os.path.join(self.site.config["OUTPUT_FOLDER"], *p_uri.path.split("/"))
    mimetype = mimetypes.guess_type(uri)[0] or "text/html"

    if os.path.isdir(f_path):
        f_path = os.path.join(f_path, self.site.config["INDEX_FILE"])

    if p_uri.path == "/robots.txt":
        start_response("200 OK", [("Content-type", "text/plain")])
        return ["User-Agent: *\nDisallow: /\n"]
    elif os.path.isfile(f_path):
        with open(f_path, "rb") as fd:
            start_response("200 OK", [("Content-type", mimetype)])
            return [self.inject_js(mimetype, fd.read())]
    elif p_uri.path == "/livereload.js":
        with open(LRJS_PATH, "rb") as fd:
            start_response("200 OK", [("Content-type", mimetype)])
            return [self.inject_js(mimetype, fd.read())]
    start_response("404 ERR", [])
    return [self.inject_js("text/html", ERROR_N.format(404).format(uri))]
# Buggy code
def _run_command(self, command, xfail=False):
    """Run a command that may or may not fail."""
    self.logger.info("==> {0}".format(command))
    try:
        subprocess.check_call(command)
        return 0
    except subprocess.CalledProcessError as e:
        if xfail:
            return e.returncode
        self.logger.error(
            "Failed GitHub deployment — command {0} returned {1}".format(
                e.cmd, e.returncode
            )
        )
        raise SystemError(e.returncode)


# Traceback (UnicodeEncodeError)
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/doit/doit_cmd.py", line 165, in run
return command.parse_execute(args)
File "/usr/lib/python3.4/site-packages/doit/cmd_base.py", line 122, in parse_execute
return self.execute(params, args)
File "/usr/lib/python3.4/site-packages/doit/cmd_help.py", line 155, in execute
six.print_(cmd.help())
UnicodeEncodeError: 'ascii' codec can't encode character '\u2013' in position 269: ordinal not in range(128)

# Fixed code
def _run_command(self, command, xfail=False):
    """Run a command that may or may not fail."""
    self.logger.info("==> {0}".format(command))
    try:
        subprocess.check_call(command)
        return 0
    except subprocess.CalledProcessError as e:
        if xfail:
            return e.returncode
        self.logger.error(
            "Failed GitHub deployment -- command {0} returned {1}".format(
                e.cmd, e.returncode
            )
        )
        raise SystemError(e.returncode)
# Buggy code
def replacement(m):
    language = m.group(1) or ""
    code = m.group(2)
    code = code.replace("&amp;", "&")
    code = code.replace("&gt;", ">")
    code = code.replace("&lt;", "<")
    code = code.replace("&quot;", '"')
    return "```{language}\n{code}\n```".format(language=language, code=code)


# Traceback (IndexError)
Traceback (most recent call last):
File "/home/ralsina/.virtualenvs/nikola/local/lib/python2.7/site-packages/doit-0.28.0-py2.7.egg/doit/doit_cmd.py", line 165, in run
return command.parse_execute(args)
File "/home/ralsina/.virtualenvs/nikola/local/lib/python2.7/site-packages/doit-0.28.0-py2.7.egg/doit/cmd_base.py", line 122, in parse_execute
return self.execute(params, args)
File "/home/ralsina/Desktop/proyectos/nikola/master/nikola/plugin_categories.py", line 125, in execute
self._execute(options, args)
File "/home/ralsina/Desktop/proyectos/nikola/master/nikola/plugins/command/import_wordpress.py", line 162, in _execute
self.import_posts(channel)
File "/home/ralsina/Desktop/proyectos/nikola/master/nikola/plugins/command/import_wordpress.py", line 512, in import_posts
self.process_item(item)
File "/home/ralsina/Desktop/proyectos/nikola/master/nikola/plugins/command/import_wordpress.py", line 506, in process_item
self.import_item(item, wordpress_namespace, 'posts')
File "/home/ralsina/Desktop/proyectos/nikola/master/nikola/plugins/command/import_wordpress.py", line 484, in import_item
content = self.transform_content(content)
File "/home/ralsina/Desktop/proyectos/nikola/master/nikola/plugins/command/import_wordpress.py", line 369, in transform_content
content = self.transform_code(content)
File "/home/ralsina/Desktop/proyectos/nikola/master/nikola/plugins/command/import_wordpress.py", line 350, in transform_code
content = self.code_re3.sub(replacement, content)
File "/home/ralsina/Desktop/proyectos/nikola/master/nikola/plugins/command/import_wordpress.py", line 341, in replacement
code = m.group(2)
IndexError: no such group

# Fixed code
def replacement(m, c=content):
    if len(m.groups()) == 1:
        language = ""
        code = m.group(0)
    else:
        language = m.group(1) or ""
        code = m.group(2)
    code = code.replace("&amp;", "&")
    code = code.replace("&gt;", ">")
    code = code.replace("&lt;", "<")
    code = code.replace("&quot;", '"')
    return "```{language}\n{code}\n```".format(language=language, code=code)
# Buggy code
def write_urlmap_csv(output_file, url_map):
    utils.makedirs(os.path.dirname(output_file))
    with io.open(output_file, "w+", encoding="utf8") as fd:
        csv_writer = csv.writer(fd)
        for item in url_map.items():
            csv_writer.writerow(item)


# Traceback (TypeError)
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/doit/doit_cmd.py", line 120, in run
return command.parse_execute(args)
File "/usr/lib/python2.7/dist-packages/doit/cmd_base.py", line 78, in parse_execute
return self.execute(params, args)
File "/home/evgeni/Devel/nikola/nikola/plugin_categories.py", line 102, in execute
self._execute(options, args)
File "/home/evgeni/Devel/nikola/nikola/plugins/command/import_wordpress.py", line 176, in _execute
os.path.join(self.output_folder, 'url_map.csv'), self.url_map)
File "/home/evgeni/Devel/nikola/nikola/plugins/basic_import.py", line 145, in write_urlmap_csv
csv_writer.writerow(item)
TypeError: must be unicode, not str

# Fixed code
def write_urlmap_csv(output_file, url_map):
    utils.makedirs(os.path.dirname(output_file))
    if sys.version_info[0] == 2:
        with io.open(output_file, "wb+") as fd:
            csv_writer = csv.writer(fd)
            for item in url_map.items():
                csv_writer.writerow(item)
    else:
        with open(output_file, "w+") as fd:
            csv_writer = csv.writer(fd)
            for item in url_map.items():
                csv_writer.writerow(item)
# Buggy code
def write_urlmap_csv(output_file, url_map):
    utils.makedirs(os.path.dirname(output_file))
    if sys.version_info[0] == 2:
        with io.open(output_file, "wb+") as fd:
            csv_writer = csv.writer(fd)
            for item in url_map.items():
                csv_writer.writerow(item)
    else:
        with open(output_file, "w+") as fd:
            csv_writer = csv.writer(fd)
            for item in url_map.items():
                csv_writer.writerow(item)


# Traceback (TypeError)
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/doit/doit_cmd.py", line 120, in run
return command.parse_execute(args)
File "/usr/lib/python2.7/dist-packages/doit/cmd_base.py", line 78, in parse_execute
return self.execute(params, args)
File "/home/evgeni/Devel/nikola/nikola/plugin_categories.py", line 102, in execute
self._execute(options, args)
File "/home/evgeni/Devel/nikola/nikola/plugins/command/import_wordpress.py", line 176, in _execute
os.path.join(self.output_folder, 'url_map.csv'), self.url_map)
File "/home/evgeni/Devel/nikola/nikola/plugins/basic_import.py", line 145, in write_urlmap_csv
csv_writer.writerow(item)
TypeError: must be unicode, not str

# Fixed code
def write_urlmap_csv(output_file, url_map):
    utils.makedirs(os.path.dirname(output_file))
    fmode = "wb+" if sys.version_info[0] == 2 else "w+"
    with io.open(output_file, fmode) as fd:
        csv_writer = csv.writer(fd)
        for item in url_map.items():
            csv_writer.writerow(item)
# Buggy code
def __init__(self):
    """initialize Jinja2 wrapper with extended set of filters"""
    if jinja2 is None:
        return
    self.lookup = jinja2.Environment()
    self.lookup.trim_blocks = True
    self.lookup.lstrip_blocks = True
    self.lookup.filters["tojson"] = json.dumps
    self.lookup.globals["enumerate"] = enumerate


# Traceback (AttributeError)
Scanning posts....done!
... omitted copy_assets ...
.  render_indexes:output/index.html
########################################
TaskError - taskid:render_indexes:output/index.html
PythonAction Error
Traceback (most recent call last):
File "/home/tritium/.virtualenvs/site/local/lib/python2.7/site-packages/doit/action.py", line 360, in execute
returned_value = self.py_callable(*self.args, **kwargs)
File "/home/tritium/.virtualenvs/site/local/lib/python2.7/site-packages/nikola/nikola.py", line 769, in render_template
template_name, None, local_context)
File "/home/tritium/.virtualenvs/site/local/lib/python2.7/site-packages/nikola/plugins/template/jinja.py", line 88, in render_template
output = template.render(**context)
File "/home/tritium/.virtualenvs/site/local/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
return self.environment.handle_exception(exc_info, True)
File "/home/tritium/.virtualenvs/site/local/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/tritium/.virtualenvs/site/local/lib/python2.7/site-packages/nikola/data/themes/base-jinja/templates/index.tmpl", line 4, in top-level template code
{% extends 'base.tmpl' %}
File "themes/bootstrap3-jinja/templates/base.tmpl", line 36, in top-level template code
{{ base.html_navigation_links() }}
File "themes/bootstrap3-jinja/templates/base_helper.tmpl", line 129, in template
{% if rel_link(permalink, url) == "#" %}
File "/home/tritium/.virtualenvs/site/local/lib/python2.7/site-packages/nikola/nikola.py", line 1056, in rel_link
dst = urljoin(src, dst)
File "/usr/lib/python2.7/urlparse.py", line 253, in urljoin
urlparse(url, bscheme, allow_fragments)
File "/usr/lib/python2.7/urlparse.py", line 135, in urlparse
tuple = urlsplit(url, scheme, allow_fragments)
File "/usr/lib/python2.7/urlparse.py", line 174, in urlsplit
i = url.find(':')
AttributeError: 'tuple' object has no attribute 'find'

# Fixed code
def __init__(self):
    """initialize Jinja2 wrapper with extended set of filters"""
    if jinja2 is None:
        return
    self.lookup = jinja2.Environment()
    self.lookup.trim_blocks = True
    self.lookup.lstrip_blocks = True
    self.lookup.filters["tojson"] = json.dumps
    self.lookup.globals["enumerate"] = enumerate
    self.lookup.globals["isinstance"] = isinstance
    self.lookup.globals["tuple"] = tuple
# Buggy code
def _commit_and_push(self):
    """Commit all the files and push."""

    deploy = self._deploy_branch
    source = self._source_branch
    remote = self._remote_name

    source_commit = subprocess.check_output(["git", "rev-parse", source])
    commit_message = "Nikola auto commit.\n\nSource commit: %sNikola version: %s" % (
        source_commit,
        __version__,
    )

    commands = [
        ["git", "add", "-A"],
        ["git", "commit", "-m", commit_message],
        ["git", "push", "-f", remote, "%s:%s" % (deploy, deploy)],
        ["git", "checkout", source],
    ]

    for command in commands:
        self.logger.info("==> {0}".format(command))
        try:
            subprocess.check_call(command)
        except subprocess.CalledProcessError as e:
            self.logger.error(
                "Failed GitHub deployment — command {0} returned {1}".format(
                    e.cmd, e.returncode
                )
            )
            sys.exit(e.returncode)


# Traceback (TypeError)
(blog)kzhang@vm1404:~/projects/blog/blog$ nikola github_deploy
Traceback (most recent call last):
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/doit/doit_cmd.py", line 120, in run
return command.parse_execute(args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/doit/cmd_base.py", line 78, in parse_execute
return self.execute(params, args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugin_categories.py", line 98, in execute
self._execute(options, args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugins/command/github_deploy.py", line 92, in _execute
self._ensure_git_repo()
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugins/command/github_deploy.py", line 226, in _ensure_git_repo
if self._remote_name not in remotes:
TypeError: Type str doesn't support the buffer API

# Fixed code
def _commit_and_push(self):
    """Commit all the files and push."""

    deploy = self._deploy_branch
    source = self._source_branch
    remote = self._remote_name

    source_commit = uni_check_output(["git", "rev-parse", source])
    commit_message = "Nikola auto commit.\n\nSource commit: %sNikola version: %s" % (
        source_commit,
        __version__,
    )

    commands = [
        ["git", "add", "-A"],
        ["git", "commit", "-m", commit_message],
        ["git", "push", "-f", remote, "%s:%s" % (deploy, deploy)],
        ["git", "checkout", source],
    ]

    for command in commands:
        self.logger.info("==> {0}".format(command))
        try:
            subprocess.check_call(command)
        except subprocess.CalledProcessError as e:
            self.logger.error(
                "Failed GitHub deployment — command {0} returned {1}".format(
                    e.cmd, e.returncode
                )
            )
            sys.exit(e.returncode)
# Buggy code
def _ensure_git_repo(self):
    """Ensure that the site is a git-repo.

    Also make sure that a remote with the specified name exists.

    """

    try:
        remotes = subprocess.check_output(["git", "remote"])
    except subprocess.CalledProcessError as e:
        self.logger.notice("github_deploy needs a git repository!")
        sys.exit(e.returncode)
    except OSError as e:
        import errno

        self.logger.error("Running git failed with {0}".format(e))
        if e.errno == errno.ENOENT:
            self.logger.notice("Is git on the PATH?")
        sys.exit(1)
    else:
        if self._remote_name not in remotes:
            self.logger.error(
                'Need a remote called "%s" configured' % self._remote_name
            )
            sys.exit(1)


# Traceback (TypeError)
(blog)kzhang@vm1404:~/projects/blog/blog$ nikola github_deploy
Traceback (most recent call last):
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/doit/doit_cmd.py", line 120, in run
return command.parse_execute(args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/doit/cmd_base.py", line 78, in parse_execute
return self.execute(params, args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugin_categories.py", line 98, in execute
self._execute(options, args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugins/command/github_deploy.py", line 92, in _execute
self._ensure_git_repo()
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugins/command/github_deploy.py", line 226, in _ensure_git_repo
if self._remote_name not in remotes:
TypeError: Type str doesn't support the buffer API

# Fixed code
def _ensure_git_repo(self):
    """Ensure that the site is a git-repo.

    Also make sure that a remote with the specified name exists.

    """

    try:
        remotes = uni_check_output(["git", "remote"])
    except subprocess.CalledProcessError as e:
        self.logger.notice("github_deploy needs a git repository!")
        sys.exit(e.returncode)
    except OSError as e:
        import errno

        self.logger.error("Running git failed with {0}".format(e))
        if e.errno == errno.ENOENT:
            self.logger.notice("Is git on the PATH?")
        sys.exit(1)
    else:
        if self._remote_name not in remotes:
            self.logger.error(
                'Need a remote called "%s" configured' % self._remote_name
            )
            sys.exit(1)
# Buggy code
def _exit_if_output_committed(self):
    """Exit if the output folder is committed on the source branch."""

    source = self._source_branch
    subprocess.check_call(["git", "checkout", source])

    output_folder = self.site.config["OUTPUT_FOLDER"]
    output_log = subprocess.check_output(["git", "ls-files", "--", output_folder])

    if len(output_log.strip()) > 0:
        self.logger.error(
            "Output folder is committed on the source branch. "
            "Cannot proceed until it is removed."
        )
        sys.exit(1)


# Traceback (TypeError)
(blog)kzhang@vm1404:~/projects/blog/blog$ nikola github_deploy
Traceback (most recent call last):
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/doit/doit_cmd.py", line 120, in run
return command.parse_execute(args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/doit/cmd_base.py", line 78, in parse_execute
return self.execute(params, args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugin_categories.py", line 98, in execute
self._execute(options, args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugins/command/github_deploy.py", line 92, in _execute
self._ensure_git_repo()
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugins/command/github_deploy.py", line 226, in _ensure_git_repo
if self._remote_name not in remotes:
TypeError: Type str doesn't support the buffer API

# Fixed code
def _exit_if_output_committed(self):
    """Exit if the output folder is committed on the source branch."""

    source = self._source_branch
    subprocess.check_call(["git", "checkout", source])

    output_folder = self.site.config["OUTPUT_FOLDER"]
    output_log = uni_check_output(["git", "ls-files", "--", output_folder])

    if len(output_log.strip()) > 0:
        self.logger.error(
            "Output folder is committed on the source branch. "
            "Cannot proceed until it is removed."
        )
        sys.exit(1)
# Buggy code
def _prompt_continue(self):
    """Show uncommitted changes, and ask if user wants to continue."""

    changes = subprocess.check_output(["git", "status", "--porcelain"])
    if changes.strip():
        changes = subprocess.check_output(["git", "status"]).strip()
        message = (
            "You have the following changes:\n%s\n\n"
            "Anything not committed, and unknown to Nikola may be lost, "
            "or committed onto the wrong branch. Do you wish to continue?"
        ) % changes
        proceed = ask_yesno(message, False)
    else:
        proceed = True

    return proceed


# Traceback (TypeError)
(blog)kzhang@vm1404:~/projects/blog/blog$ nikola github_deploy
Traceback (most recent call last):
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/doit/doit_cmd.py", line 120, in run
return command.parse_execute(args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/doit/cmd_base.py", line 78, in parse_execute
return self.execute(params, args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugin_categories.py", line 98, in execute
self._execute(options, args)
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugins/command/github_deploy.py", line 92, in _execute
self._ensure_git_repo()
File "/home/kzhang/projects/blog/lib/python3.4/site-packages/nikola/plugins/command/github_deploy.py", line 226, in _ensure_git_repo
if self._remote_name not in remotes:
TypeError: Type str doesn't support the buffer API

# Fixed code
def _prompt_continue(self):
    """Show uncommitted changes, and ask if user wants to continue."""

    changes = uni_check_output(["git", "status", "--porcelain"])
    if changes.strip():
        changes = uni_check_output(["git", "status"]).strip()
        message = (
            "You have the following changes:\n%s\n\n"
            "Anything not committed, and unknown to Nikola may be lost, "
            "or committed onto the wrong branch. Do you wish to continue?"
        ) % changes
        proceed = ask_yesno(message, False)
    else:
        proceed = True

    return proceed
# Buggy code
def __repr__(self):
    return "<Nikola Site: {0}>".format(self.config["BLOG_TITLE"]())


# Traceback (UnicodeEncodeError)
Scanning posts....done!
########################################
DependencyError - taskid:render_galleries:output/galleries
ERROR: Task 'render_galleries:output/galleries' checking dependencies
Traceback (most recent call last):
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/doit/runner.py", line 124, in select_task
node.run_status = self.dep_manager.get_status(task, tasks_dict)
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/doit/dependency.py", line 483, in get_status
uptodate_result = utd(*args, **utd_kwargs)
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/doit/tools.py", line 122, in __call__
self.config_digest = self._calc_digest()
File "/home/kwpolska/git/nikola/nikola/utils.py", line 501, in _calc_digest
data = json.dumps(self.config, cls=CustomEncoder, sort_keys=True)
File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
sort_keys=sort_keys, **kw).encode(obj)
File "/usr/lib64/python2.7/json/encoder.py", line 209, in encode
chunks = list(chunks)
File "/usr/lib64/python2.7/json/encoder.py", line 434, in _iterencode
for chunk in _iterencode_dict(o, _current_indent_level):
File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
for chunk in chunks:
File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
for chunk in chunks:
File "/usr/lib64/python2.7/json/encoder.py", line 442, in _iterencode
o = _default(o)
File "/home/kwpolska/git/nikola/nikola/utils.py", line 488, in default
return super(CustomEncoder, self).default(obj)
File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 20: ordinal not in range(128)

# Fixed code
def __repr__(self):
    return "<Nikola Site: {0!r}>".format(self.config["BLOG_TITLE"]())
# Buggy code
def __repr__(self):
    """Provide a representation for programmers."""
    header = "<TranslatableSetting> "

    if not self.translated:
        values = [repr(self())]
    else:
        values = ["{0}={1!r}".format(k, v) for k, v in self.values.items()]

    return header + ", ".join(values)


# Traceback (UnicodeEncodeError)
Scanning posts....done!
########################################
DependencyError - taskid:render_galleries:output/galleries
ERROR: Task 'render_galleries:output/galleries' checking dependencies
Traceback (most recent call last):
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/doit/runner.py", line 124, in select_task
node.run_status = self.dep_manager.get_status(task, tasks_dict)
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/doit/dependency.py", line 483, in get_status
uptodate_result = utd(*args, **utd_kwargs)
File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/doit/tools.py", line 122, in __call__
self.config_digest = self._calc_digest()
File "/home/kwpolska/git/nikola/nikola/utils.py", line 501, in _calc_digest
data = json.dumps(self.config, cls=CustomEncoder, sort_keys=True)
File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
sort_keys=sort_keys, **kw).encode(obj)
File "/usr/lib64/python2.7/json/encoder.py", line 209, in encode
chunks = list(chunks)
File "/usr/lib64/python2.7/json/encoder.py", line 434, in _iterencode
for chunk in _iterencode_dict(o, _current_indent_level):
File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
for chunk in chunks:
File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
for chunk in chunks:
File "/usr/lib64/python2.7/json/encoder.py", line 442, in _iterencode
o = _default(o)
File "/home/kwpolska/git/nikola/nikola/utils.py", line 488, in default
return super(CustomEncoder, self).default(obj)
File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 20: ordinal not in range(128)

# Fixed code
def __repr__(self):
    """Provide a representation for programmers."""
    return "<TranslatableSetting: {0!r}>".format(self.name)
# Buggy code
def current_time(tzinfo=None):
    if tzinfo is not None:
        dt = datetime.datetime.utcnow()
        dt = tzinfo.fromutc(dt)
    else:
        dt = datetime.datetime.now(dateutil.tz.tzlocal())
    return dt


# Traceback (TypeError)
ERROR:yapsy:Unable to import plugin: /usr/local/lib/python2.7/dist-    packages/nikola/plugins/compile/rest/listing
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/yapsy/PluginManager.py", line 487, in  loadPlugins
candidate_module =  imp.load_module(plugin_module_name,plugin_file,candidate_filepath+".py",("py","r",imp.PY_SOURCE))
File "/usr/local/lib/python2.7/dist-packages/nikola/plugins/compile/rest/listing.py", line 60, in <module>
CodeBlock.option_spec['linenos'] = directives.unchanged
TypeError: 'NoneType' object does not support item assignment

# Fixed code
def current_time(tzinfo=None):
    if tzinfo is not None:
        dt = datetime.datetime.now(tzinfo)
    else:
        dt = datetime.datetime.now(dateutil.tz.tzlocal())
    return dt
# Buggy code
def _execute(self, options, args):
    """Start the watcher."""
    try:
        from livereload.server import start
    except ImportError:
        req_missing(["livereload==1.0.1"], 'use the "auto" command')
        return

    # Run an initial build so we are uptodate
    subprocess.call(("nikola", "build"))

    port = options and options.get("port")

    # Create a Guardfile
    with codecs.open("Guardfile", "wb+", "utf8") as guardfile:
        l = ["conf.py", "themes", "templates", self.site.config["GALLERY_PATH"]]
        for item in self.site.config["post_pages"]:
            l.append(os.path.dirname(item[0]))
        for item in self.site.config["FILES_FOLDERS"]:
            l.append(os.path.dirname(item))
        data = GUARDFILE.format(json.dumps(l))
        guardfile.write(data)

    out_folder = self.site.config["OUTPUT_FOLDER"]

    os.chmod("Guardfile", 0o755)

    start(port, out_folder, options and options.get("browser"))


# Traceback (Exception)
$ nikola auto
[2014-01-02T13:30:46Z] ERROR: Nikola: In order to use the "auto" command, you must install the "livereload" Python package.
Traceback (most recent call last):
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/doit/doit_cmd.py", line 105, in run
return self.sub_cmds[command].parse_execute(args)
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/doit/cmd_base.py", line 76, in parse_execute
return self.execute(params, args)
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/nikola/plugin_categories.py", line 77, in execute
self._execute(options, args)
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/nikola/plugins/command/auto.py", line 81, in _execute
req_missing(['livereload'], 'use the "auto" command')
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/nikola/utils.py", line 104, in req_missing
raise Exception('Missing dependencies: {0}'.format(', '.join(names)))
Exception: Missing dependencies: livereload

# Fixed code
def _execute(self, options, args):
    """Start the watcher."""
    try:
        from livereload import Server
    except ImportError:
        req_missing(["livereload>=2.0"], 'use the "auto" command')
        return

    # Run an initial build so we are uptodate
    subprocess.call(("nikola", "build"))

    port = options and options.get("port")

    server = Server()
    server.watch("conf.py")
    server.watch("themes/")
    server.watch("templates/")
    server.watch(self.site.config["GALLERY_PATH"])
    for item in self.site.config["post_pages"]:
        server.watch(os.path.dirname(item[0]))
    for item in self.site.config["FILES_FOLDERS"]:
        server.watch(os.path.dirname(item))

    out_folder = self.site.config["OUTPUT_FOLDER"]
    if options and options.get("browser"):
        webbrowser.open("http://localhost:{0}".format(port))

    server.serve(port, out_folder)
# Buggy code
def _execute(self, options, args):
    """Start the watcher."""
    try:
        from livereload.server import start
    except ImportError:
        req_missing(["livereload"], 'use the "auto" command')
        return

    # Run an initial build so we are uptodate
    subprocess.call(("nikola", "build"))

    port = options and options.get("port")

    # Create a Guardfile
    with codecs.open("Guardfile", "wb+", "utf8") as guardfile:
        l = ["conf.py", "themes", "templates", self.site.config["GALLERY_PATH"]]
        for item in self.site.config["post_pages"]:
            l.append(os.path.dirname(item[0]))
        for item in self.site.config["FILES_FOLDERS"]:
            l.append(os.path.dirname(item))
        data = GUARDFILE.format(json.dumps(l))
        guardfile.write(data)

    out_folder = self.site.config["OUTPUT_FOLDER"]

    os.chmod("Guardfile", 0o755)

    start(port, out_folder, options and options.get("browser"))


# Traceback (Exception)
$ nikola auto
[2014-01-02T13:30:46Z] ERROR: Nikola: In order to use the "auto" command, you must install the "livereload" Python package.
Traceback (most recent call last):
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/doit/doit_cmd.py", line 105, in run
return self.sub_cmds[command].parse_execute(args)
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/doit/cmd_base.py", line 76, in parse_execute
return self.execute(params, args)
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/nikola/plugin_categories.py", line 77, in execute
self._execute(options, args)
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/nikola/plugins/command/auto.py", line 81, in _execute
req_missing(['livereload'], 'use the "auto" command')
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/nikola/utils.py", line 104, in req_missing
raise Exception('Missing dependencies: {0}'.format(', '.join(names)))
Exception: Missing dependencies: livereload

# Fixed code
def _execute(self, options, args):
    """Start the watcher."""
    try:
        from livereload.server import start
    except ImportError:
        req_missing(["livereload==1.0.1"], 'use the "auto" command')
        return

    # Run an initial build so we are uptodate
    subprocess.call(("nikola", "build"))

    port = options and options.get("port")

    # Create a Guardfile
    with codecs.open("Guardfile", "wb+", "utf8") as guardfile:
        l = ["conf.py", "themes", "templates", self.site.config["GALLERY_PATH"]]
        for item in self.site.config["post_pages"]:
            l.append(os.path.dirname(item[0]))
        for item in self.site.config["FILES_FOLDERS"]:
            l.append(os.path.dirname(item))
        data = GUARDFILE.format(json.dumps(l))
        guardfile.write(data)

    out_folder = self.site.config["OUTPUT_FOLDER"]

    os.chmod("Guardfile", 0o755)

    start(port, out_folder, options and options.get("browser"))
# Buggy code
def _execute(self, options, args):
    """Start the watcher."""
    try:
        from livereload import Server
    except ImportError:
        req_missing(["livereload>=2.0"], 'use the "auto" command')
        return

    # Run an initial build so we are uptodate
    subprocess.call(("nikola", "build"))

    port = options and options.get("port")

    server = Server()
    server.watch("conf.py")
    server.watch("themes/")
    server.watch("templates/")
    server.watch(self.site.config["GALLERY_PATH"])
    for item in self.site.config["post_pages"]:
        server.watch(os.path.dirname(item[0]))
    for item in self.site.config["FILES_FOLDERS"]:
        server.watch(os.path.dirname(item))

    out_folder = self.site.config["OUTPUT_FOLDER"]
    if options and options.get("browser"):
        webbrowser.open("http://localhost:{0}".format(port))

    server.serve(port, out_folder)


# Traceback (Exception)
$ nikola auto
[2014-01-02T13:30:46Z] ERROR: Nikola: In order to use the "auto" command, you must install the "livereload" Python package.
Traceback (most recent call last):
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/doit/doit_cmd.py", line 105, in run
return self.sub_cmds[command].parse_execute(args)
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/doit/cmd_base.py", line 76, in parse_execute
return self.execute(params, args)
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/nikola/plugin_categories.py", line 77, in execute
self._execute(options, args)
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/nikola/plugins/command/auto.py", line 81, in _execute
req_missing(['livereload'], 'use the "auto" command')
File "/home/simon/.pyenv/versions/nikola/lib/python2.7/site-packages/nikola/utils.py", line 104, in req_missing
raise Exception('Missing dependencies: {0}'.format(', '.join(names)))
Exception: Missing dependencies: livereload

# Fixed code
def _execute(self, options, args):
    """Start the watcher."""
    try:
        from livereload import Server
    except ImportError:
        req_missing(["livereload>=2.0.0"], 'use the "auto" command')
        return

    # Run an initial build so we are uptodate
    subprocess.call(("nikola", "build"))

    port = options and options.get("port")

    server = Server()
    server.watch("conf.py")
    server.watch("themes/")
    server.watch("templates/")
    server.watch(self.site.config["GALLERY_PATH"])
    for item in self.site.config["post_pages"]:
        server.watch(os.path.dirname(item[0]))
    for item in self.site.config["FILES_FOLDERS"]:
        server.watch(os.path.dirname(item))

    out_folder = self.site.config["OUTPUT_FOLDER"]
    if options and options.get("browser"):
        webbrowser.open("http://localhost:{0}".format(port))

    server.serve(port, out_folder)
# Buggy code
def _create_record_and_aggregate_column(
    trial: "optuna.trial.FrozenTrial",
) -> Dict[Tuple[str, str], Any]:
    record = {}
    for attr, df_column in attrs_to_df_columns.items():
        value = getattr(trial, attr)
        if isinstance(value, TrialState):
            # Convert TrialState to str and remove the common prefix.
            value = str(value).split(".")[-1]
        if isinstance(value, dict):
            for nested_attr, nested_value in value.items():
                record[(df_column, nested_attr)] = nested_value
                column_agg[attr].add((df_column, nested_attr))
        elif isinstance(value, list):
            # Expand trial.values.
            for nested_attr, nested_value in enumerate(value):
                record[(df_column, nested_attr)] = nested_value
                column_agg[attr].add((df_column, nested_attr))
        else:
            record[(df_column, non_nested_attr)] = value
            column_agg[attr].add((df_column, non_nested_attr))
    return record


# Traceback (TypeError)
Traceback (most recent call last):
File "optuna_vis.py", line 12, in <module>
study_df = study.trials_dataframe()
File "/home/user.name/anaconda3/lib/python3.8/site-packages/optuna/study.py", line 499, in trials_dataframe
return _trials_dataframe(self, attrs, multi_index)
File "/home/user.name/anaconda3/lib/python3.8/site-packages/optuna/_dataframe.py", line 80, in _trials_dataframe
columns: List[Tuple[str, str]] = sum(
File "/home/user.name/anaconda3/lib/python3.8/site-packages/optuna/_dataframe.py", line 81, in <genexpr>
(sorted(column_agg[k]) for k in attrs if k in column_agg), []
TypeError: '<' not supported between instances of 'str' and 'int'

# Fixed code
def _create_record_and_aggregate_column(
    trial: "optuna.trial.FrozenTrial",
) -> Dict[Tuple[str, str], Any]:
    record = {}
    for attr, df_column in attrs_to_df_columns.items():
        value = getattr(trial, attr)
        if isinstance(value, TrialState):
            # Convert TrialState to str and remove the common prefix.
            value = str(value).split(".")[-1]
        if isinstance(value, dict):
            for nested_attr, nested_value in value.items():
                record[(df_column, nested_attr)] = nested_value
                column_agg[attr].add((df_column, nested_attr))
        elif isinstance(value, list):
            # Expand trial.values.
            for nested_attr, nested_value in enumerate(value):
                record[(df_column, nested_attr)] = nested_value
                column_agg[attr].add((df_column, nested_attr))
        elif attr == "values":
            # trial.values should be None when the trial's state is FAIL or PRUNED.
            assert value is None
            for nested_attr in range(len(study.directions)):
                record[(df_column, nested_attr)] = None
                column_agg[attr].add((df_column, nested_attr))
        else:
            record[(df_column, non_nested_attr)] = value
            column_agg[attr].add((df_column, non_nested_attr))
    return record