gurudesh/pytracebugs huggingface dataset:
# Buggy code
def __iter__(self) -> Iterator[FilePath]:
    ext = "[!.#~]*" + self.extension

    root = self.project.project_root

    for result in find_matching(root, self.relative_dirs, ext):
        file_match = FilePath(**{k: os.path.normcase(v) for k, v in result.items()})
        yield file_match


# Traceback (FileNotFoundError)
2019-09-04 16:36:25,854704 (MainThread): Acquiring new postgres connection "seedtable".
2019-09-04 16:36:25,854894 (MainThread): Re-using an available connection from the pool (formerly model_2).
2019-09-04 16:36:25,963811 (MainThread): Unhandled error while executing seed.minimal.seedtable
[Errno 2] No such file or directory: 'data/seedtable.csv'
2019-09-04 16:36:25,964249 (MainThread):
Traceback (most recent call last):
File "/Users/jake/src/fishtown/dbt/core/dbt/node_runners.py", line 203, in safe_run
result = self.compile_and_execute(manifest, ctx)
File "/Users/jake/src/fishtown/dbt/core/dbt/node_runners.py", line 146, in compile_and_execute
result = self.run(ctx.node, manifest)
File "/Users/jake/src/fishtown/dbt/core/dbt/node_runners.py", line 245, in run
return self.execute(compiled_node, manifest)
File "/Users/jake/src/fishtown/dbt/core/dbt/node_runners.py", line 357, in execute
materialization_macro.generator(context)()
File "/Users/jake/src/fishtown/dbt/core/dbt/clients/jinja.py", line 127, in call
return macro(*args, **kwargs)
File "/Users/jake/.pyenv/versions/3.6.5/envs/dbt36/lib/python3.6/site-packages/jinja2/runtime.py", line 575, in __call__
return self._invoke(arguments, autoescape)
File "/Users/jake/.pyenv/versions/3.6.5/envs/dbt36/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 110, in _invoke
return original_invoke(self, arguments, autoescape)
File "/Users/jake/.pyenv/versions/3.6.5/envs/dbt36/lib/python3.6/site-packages/jinja2/runtime.py", line 579, in _invoke
rv = self._func(*arguments)
File "<template>", line 346, in macro
File "/Users/jake/.pyenv/versions/3.6.5/envs/dbt36/lib/python3.6/site-packages/jinja2/sandbox.py", line 438, in call
return __context.call(__obj, *args, **kwargs)
File "/Users/jake/.pyenv/versions/3.6.5/envs/dbt36/lib/python3.6/site-packages/jinja2/runtime.py", line 262, in call
return __obj(*args, **kwargs)
File "/Users/jake/src/fishtown/dbt/core/dbt/context/common.py", line 364, in load_agate_table
table = dbt.clients.agate_helper.from_csv(path)
File "/Users/jake/src/fishtown/dbt/core/dbt/clients/agate_helper.py", line 65, in from_csv
with open(abspath, encoding='utf-8') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'data/seedtable.csv'

# Fixed code
def __iter__(self) -> Iterator[FilePath]:
    ext = "[!.#~]*" + self.extension

    root = self.project.project_root

    for result in find_matching(root, self.relative_dirs, ext):
        if "searched_path" not in result or "relative_path" not in result:
            raise InternalException(
                "Invalid result from find_matching: {}".format(result)
            )
        file_match = FilePath(
            searched_path=result["searched_path"],
            relative_path=result["relative_path"],
            project_root=root,
        )
        yield file_match
# Buggy code
def show_table(self, result):
    table = result.node["agate_table"]
    rand_table = table.order_by(lambda x: random.random())

    schema = result.node["schema"]
    alias = result.node["alias"]

    header = "Random sample of table: {}.{}".format(schema, alias)
    logger.info("")
    logger.info(header)
    logger.info("-" * len(header))
    rand_table.print_table(max_rows=10, max_columns=None)
    logger.info("")


# Traceback (KeyError)
2019-02-12 10:58:28,566 (MainThread): Sending event: {'category': 'dbt', 'action': 'invocation', 'label': 'end', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x10bcc7e48>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x108697518>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x10bca7358>]}
2019-02-12 10:58:29,028 (MainThread): Flushing usage events
2019-02-12 10:58:29,028 (MainThread): Encountered an error:
2019-02-12 10:58:29,029 (MainThread): 'agate_table'
2019-02-12 10:58:29,029 (MainThread): Traceback (most recent call last):
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/main.py", line 77, in main
results, succeeded = handle_and_check(args)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/main.py", line 151, in handle_and_check
task, res = run_from_args(parsed)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/main.py", line 207, in run_from_args
results = run_from_task(task, cfg, parsed)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/main.py", line 215, in run_from_task
result = task.run()
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/task/seed.py", line 20, in run
self.show_tables(results)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/task/seed.py", line 42, in show_tables
self.show_table(result)
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/task/seed.py", line 26, in show_table
table = result.node['agate_table']
File "/usr/local/Cellar/dbt/0.12.2/libexec/lib/python3.7/site-packages/dbt/api/object.py", line 93, in __getitem__
return self._contents[key]
KeyError: 'agate_table'

# Fixed code
def show_table(self, result):
    table = result.node.agate_table
    rand_table = table.order_by(lambda x: random.random())

    schema = result.node.schema
    alias = result.node.alias

    header = "Random sample of table: {}.{}".format(schema, alias)
    logger.info("")
    logger.info(header)
    logger.info("-" * len(header))
    rand_table.print_table(max_rows=10, max_columns=None)
    logger.info("")
# Buggy code
def clone(repo, cwd, dirname=None, remove_git_dir=False):
    clone_cmd = ["git", "clone", "--depth", "1", repo]

    if dirname is not None:
        clone_cmd.append(dirname)

    result = run_cmd(cwd, clone_cmd)

    if remove_git_dir:
        rmdir(os.path.join(dirname, ".git"))

    return result


# Traceback (AttributeError)
analytics-core git:(master) 1M 2A ₹ LC_ALL=es_ES dbt deps
Encountered an error:
'NoneType' object has no attribute 'group'
Traceback (most recent call last):
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 126, in handle_and_check
task, res = run_from_args(parsed)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 181, in run_from_args
results = run_from_task(task, cfg, parsed)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 189, in run_from_task
result = task.run()
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 439, in run
target_config = final_deps[name].fetch_metadata(self.config)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 83, in fetch_metadata
self._cached_metadata = self._fetch_metadata(project)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 239, in _fetch_metadata
path = self._checkout(project)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 235, in _checkout
dirname=self._checkout_name)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/clients/git.py", line 77, in clone_and_checkout
directory = matches.group(1)
AttributeError: 'NoneType' object has no attribute 'group'

# Fixed code
def clone(repo, cwd, dirname=None, remove_git_dir=False):
    clone_cmd = ["git", "clone", "--depth", "1", repo]

    if dirname is not None:
        clone_cmd.append(dirname)

    result = run_cmd(cwd, clone_cmd, env={"LC_ALL": "C"})

    if remove_git_dir:
        rmdir(os.path.join(dirname, ".git"))

    return result
# Buggy code
def list_tags(cwd):
    out, err = run_cmd(cwd, ["git", "tag", "--list"])
    tags = out.decode("utf-8").strip().split("\n")
    return tags


# Traceback (AttributeError)
analytics-core git:(master) 1M 2A ₹ LC_ALL=es_ES dbt deps
Encountered an error:
'NoneType' object has no attribute 'group'
Traceback (most recent call last):
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 126, in handle_and_check
task, res = run_from_args(parsed)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 181, in run_from_args
results = run_from_task(task, cfg, parsed)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 189, in run_from_task
result = task.run()
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 439, in run
target_config = final_deps[name].fetch_metadata(self.config)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 83, in fetch_metadata
self._cached_metadata = self._fetch_metadata(project)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 239, in _fetch_metadata
path = self._checkout(project)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 235, in _checkout
dirname=self._checkout_name)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/clients/git.py", line 77, in clone_and_checkout
directory = matches.group(1)
AttributeError: 'NoneType' object has no attribute 'group'

# Fixed code
def list_tags(cwd):
    out, err = run_cmd(cwd, ["git", "tag", "--list"], env={"LC_ALL": "C"})
    tags = out.decode("utf-8").strip().split("\n")
    return tags
# Buggy code
def _checkout(cwd, repo, branch):
    logger.debug("  Checking out branch {}.".format(branch))

    run_cmd(cwd, ["git", "remote", "set-branches", "origin", branch])
    run_cmd(cwd, ["git", "fetch", "--tags", "--depth", "1", "origin", branch])

    tags = list_tags(cwd)

    # Prefer tags to branches if one exists
    if branch in tags:
        spec = "tags/{}".format(branch)
    else:
        spec = "origin/{}".format(branch)

    out, err = run_cmd(cwd, ["git", "reset", "--hard", spec])
    return out, err


# Traceback (AttributeError)
analytics-core git:(master) 1M 2A ₹ LC_ALL=es_ES dbt deps
Encountered an error:
'NoneType' object has no attribute 'group'
Traceback (most recent call last):
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 126, in handle_and_check
task, res = run_from_args(parsed)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 181, in run_from_args
results = run_from_task(task, cfg, parsed)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 189, in run_from_task
result = task.run()
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 439, in run
target_config = final_deps[name].fetch_metadata(self.config)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 83, in fetch_metadata
self._cached_metadata = self._fetch_metadata(project)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 239, in _fetch_metadata
path = self._checkout(project)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 235, in _checkout
dirname=self._checkout_name)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/clients/git.py", line 77, in clone_and_checkout
directory = matches.group(1)
AttributeError: 'NoneType' object has no attribute 'group'

# Fixed code
def _checkout(cwd, repo, branch):
    logger.debug("  Checking out branch {}.".format(branch))

    run_cmd(cwd, ["git", "remote", "set-branches", "origin", branch])
    run_cmd(cwd, ["git", "fetch", "--tags", "--depth", "1", "origin", branch])

    tags = list_tags(cwd)

    # Prefer tags to branches if one exists
    if branch in tags:
        spec = "tags/{}".format(branch)
    else:
        spec = "origin/{}".format(branch)

    out, err = run_cmd(cwd, ["git", "reset", "--hard", spec], env={"LC_ALL": "C"})
    return out, err
# Buggy code
def get_current_sha(cwd):
    out, err = run_cmd(cwd, ["git", "rev-parse", "HEAD"])

    return out.decode("utf-8")


# Traceback (AttributeError)
analytics-core git:(master) 1M 2A ₹ LC_ALL=es_ES dbt deps
Encountered an error:
'NoneType' object has no attribute 'group'
Traceback (most recent call last):
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 126, in handle_and_check
task, res = run_from_args(parsed)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 181, in run_from_args
results = run_from_task(task, cfg, parsed)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 189, in run_from_task
result = task.run()
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 439, in run
target_config = final_deps[name].fetch_metadata(self.config)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 83, in fetch_metadata
self._cached_metadata = self._fetch_metadata(project)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 239, in _fetch_metadata
path = self._checkout(project)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 235, in _checkout
dirname=self._checkout_name)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/clients/git.py", line 77, in clone_and_checkout
directory = matches.group(1)
AttributeError: 'NoneType' object has no attribute 'group'

# Fixed code
def get_current_sha(cwd):
    out, err = run_cmd(cwd, ["git", "rev-parse", "HEAD"], env={"LC_ALL": "C"})

    return out.decode("utf-8")
# Buggy code
def remove_remote(cwd):
    return run_cmd(cwd, ["git", "remote", "rm", "origin"])


# Traceback (AttributeError)
analytics-core git:(master) 1M 2A ₹ LC_ALL=es_ES dbt deps
Encountered an error:
'NoneType' object has no attribute 'group'
Traceback (most recent call last):
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 126, in handle_and_check
task, res = run_from_args(parsed)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 181, in run_from_args
results = run_from_task(task, cfg, parsed)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/main.py", line 189, in run_from_task
result = task.run()
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 439, in run
target_config = final_deps[name].fetch_metadata(self.config)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 83, in fetch_metadata
self._cached_metadata = self._fetch_metadata(project)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 239, in _fetch_metadata
path = self._checkout(project)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/task/deps.py", line 235, in _checkout
dirname=self._checkout_name)
File "/Users/vijay/.pyenv/versions/3.6.5/lib/python3.6/site-packages/dbt/clients/git.py", line 77, in clone_and_checkout
directory = matches.group(1)
AttributeError: 'NoneType' object has no attribute 'group'

# Fixed code
def remove_remote(cwd):
    return run_cmd(cwd, ["git", "remote", "rm", "origin"], env={"LC_ALL": "C"})
# Buggy code
def __init__(
    self,
    profile_name,
    target_name,
    send_anonymous_usage_stats,
    use_colors,
    threads,
    credentials,
):
    self.profile_name = profile_name
    self.target_name = target_name
    self.send_anonymous_usage_stats = send_anonymous_usage_stats
    self.use_colors = use_colors
    self.threads = threads
    self.credentials = credentials


# Traceback (PermissionError)
[Errno 13] Permission denied: '/.dbt'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 120, in handle_and_check
dbt.tracking.initialize_tracking()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 275, in initialize_tracking
active_user.initialize()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 51, in initialize
cookie = self.get_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 71, in get_cookie
user = self.set_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 62, in set_cookie
dbt.clients.system.make_directory(cookie_dir)
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 85, in make_directory
raise e
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 79, in make_directory
os.makedirs(path)
File "/usr/local/lib/python3.7/os.py", line 221, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.dbt'

# Fixed code
def __init__(self, profile_name, target_name, config, threads, credentials):
    self.profile_name = profile_name
    self.target_name = target_name
    if isinstance(config, dict):
        config = UserConfig.from_dict(config)
    self.config = config
    self.threads = threads
    self.credentials = credentials
# Buggy code
def to_profile_info(self, serialize_credentials=False):
    """Unlike to_project_config, this dict is not a mirror of any existing
    on-disk data structure. It's used when creating a new profile from an
    existing one.

    :param serialize_credentials bool: If True, serialize the credentials.
        Otherwise, the Credentials object will be copied.
    :returns dict: The serialized profile.
    """
    result = {
        "profile_name": self.profile_name,
        "target_name": self.target_name,
        "send_anonymous_usage_stats": self.send_anonymous_usage_stats,
        "use_colors": self.use_colors,
        "threads": self.threads,
        "credentials": self.credentials.incorporate(),
    }
    if serialize_credentials:
        result["credentials"] = result["credentials"].serialize()
    return result


# Traceback (PermissionError)
[Errno 13] Permission denied: '/.dbt'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 120, in handle_and_check
dbt.tracking.initialize_tracking()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 275, in initialize_tracking
active_user.initialize()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 51, in initialize
cookie = self.get_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 71, in get_cookie
user = self.set_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 62, in set_cookie
dbt.clients.system.make_directory(cookie_dir)
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 85, in make_directory
raise e
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 79, in make_directory
os.makedirs(path)
File "/usr/local/lib/python3.7/os.py", line 221, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.dbt'

# Fixed code
def to_profile_info(self, serialize_credentials=False):
    """Unlike to_project_config, this dict is not a mirror of any existing
    on-disk data structure. It's used when creating a new profile from an
    existing one.

    :param serialize_credentials bool: If True, serialize the credentials.
        Otherwise, the Credentials object will be copied.
    :returns dict: The serialized profile.
    """
    result = {
        "profile_name": self.profile_name,
        "target_name": self.target_name,
        "config": self.config.to_dict(),
        "threads": self.threads,
        "credentials": self.credentials.incorporate(),
    }
    if serialize_credentials:
        result["credentials"] = result["credentials"].serialize()
    return result
# Buggy code
def handle_and_check(args):
    parsed = parse_args(args)
    profiler_enabled = False

    if parsed.record_timing_info:
        profiler_enabled = True

    with dbt.profiler.profiler(
        enable=profiler_enabled, outfile=parsed.record_timing_info
    ):
        # this needs to happen after args are parsed so we can determine the
        # correct profiles.yml file
        profile_config = read_config(parsed.profiles_dir)
        if not send_anonymous_usage_stats(profile_config):
            dbt.tracking.do_not_track()
        else:
            dbt.tracking.initialize_tracking()

        if colorize_output(profile_config):
            dbt.ui.printer.use_colors()

        reset_adapters()

        try:
            task, res = run_from_args(parsed)
        finally:
            dbt.tracking.flush()

        success = task.interpret_results(res)

        return res, success


# Traceback (PermissionError)
[Errno 13] Permission denied: '/.dbt'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 120, in handle_and_check
dbt.tracking.initialize_tracking()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 275, in initialize_tracking
active_user.initialize()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 51, in initialize
cookie = self.get_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 71, in get_cookie
user = self.set_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 62, in set_cookie
dbt.clients.system.make_directory(cookie_dir)
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 85, in make_directory
raise e
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 79, in make_directory
os.makedirs(path)
File "/usr/local/lib/python3.7/os.py", line 221, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.dbt'

# Fixed code
def handle_and_check(args):
    parsed = parse_args(args)
    profiler_enabled = False

    if parsed.record_timing_info:
        profiler_enabled = True

    with dbt.profiler.profiler(
        enable=profiler_enabled, outfile=parsed.record_timing_info
    ):
        initialize_config_values(parsed)

        reset_adapters()

        try:
            task, res = run_from_args(parsed)
        finally:
            dbt.tracking.flush()

        success = task.interpret_results(res)

        return res, success
# Buggy code
def __init__(self):
    self.do_not_track = True

    self.id = None
    self.invocation_id = str(uuid.uuid4())
    self.run_started_at = datetime.now(tz=pytz.utc)


# Traceback (PermissionError)
[Errno 13] Permission denied: '/.dbt'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 120, in handle_and_check
dbt.tracking.initialize_tracking()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 275, in initialize_tracking
active_user.initialize()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 51, in initialize
cookie = self.get_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 71, in get_cookie
user = self.set_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 62, in set_cookie
dbt.clients.system.make_directory(cookie_dir)
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 85, in make_directory
raise e
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 79, in make_directory
os.makedirs(path)
File "/usr/local/lib/python3.7/os.py", line 221, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.dbt'

# Fixed code
def __init__(self, cookie_dir):
    self.do_not_track = True
    self.cookie_dir = cookie_dir

    self.id = None
    self.invocation_id = str(uuid.uuid4())
    self.run_started_at = datetime.now(tz=pytz.utc)
# Buggy code
def set_cookie(self):
    cookie_dir = os.path.dirname(COOKIE_PATH)
    user = {"id": str(uuid.uuid4())}

    dbt.clients.system.make_directory(cookie_dir)

    with open(COOKIE_PATH, "w") as fh:
        yaml.dump(user, fh)

    return user


# Traceback (PermissionError)
[Errno 13] Permission denied: '/.dbt'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 120, in handle_and_check
dbt.tracking.initialize_tracking()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 275, in initialize_tracking
active_user.initialize()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 51, in initialize
cookie = self.get_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 71, in get_cookie
user = self.set_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 62, in set_cookie
dbt.clients.system.make_directory(cookie_dir)
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 85, in make_directory
raise e
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 79, in make_directory
os.makedirs(path)
File "/usr/local/lib/python3.7/os.py", line 221, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.dbt'

# Fixed code
def set_cookie(self):
    user = {"id": str(uuid.uuid4())}

    dbt.clients.system.make_directory(self.cookie_dir)

    with open(self.cookie_path, "w") as fh:
        yaml.dump(user, fh)

    return user
# Buggy code
def get_cookie(self):
    if not os.path.isfile(COOKIE_PATH):
        user = self.set_cookie()
    else:
        with open(COOKIE_PATH, "r") as fh:
            try:
                user = yaml.safe_load(fh)
                if user is None:
                    user = self.set_cookie()
            except yaml.reader.ReaderError:
                user = self.set_cookie()
    return user


# Traceback (PermissionError)
[Errno 13] Permission denied: '/.dbt'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 120, in handle_and_check
dbt.tracking.initialize_tracking()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 275, in initialize_tracking
active_user.initialize()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 51, in initialize
cookie = self.get_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 71, in get_cookie
user = self.set_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 62, in set_cookie
dbt.clients.system.make_directory(cookie_dir)
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 85, in make_directory
raise e
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 79, in make_directory
os.makedirs(path)
File "/usr/local/lib/python3.7/os.py", line 221, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.dbt'

# Fixed code
def get_cookie(self):
    if not os.path.isfile(self.cookie_path):
        user = self.set_cookie()
    else:
        with open(self.cookie_path, "r") as fh:
            try:
                user = yaml.safe_load(fh)
                if user is None:
                    user = self.set_cookie()
            except yaml.reader.ReaderError:
                user = self.set_cookie()
    return user
# Buggy code
def do_not_track():
    global active_user
    active_user = User()


# Traceback (PermissionError)
[Errno 13] Permission denied: '/.dbt'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 120, in handle_and_check
dbt.tracking.initialize_tracking()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 275, in initialize_tracking
active_user.initialize()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 51, in initialize
cookie = self.get_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 71, in get_cookie
user = self.set_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 62, in set_cookie
dbt.clients.system.make_directory(cookie_dir)
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 85, in make_directory
raise e
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 79, in make_directory
os.makedirs(path)
File "/usr/local/lib/python3.7/os.py", line 221, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.dbt'

# Fixed code
def do_not_track():
    global active_user
    active_user = User(None)
# Buggy code
def initialize_tracking():
    global active_user
    active_user = User()
    active_user.initialize()


# Traceback (PermissionError)
[Errno 13] Permission denied: '/.dbt'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 76, in main
results, succeeded = handle_and_check(args)
File "/usr/local/lib/python3.7/site-packages/dbt/main.py", line 120, in handle_and_check
dbt.tracking.initialize_tracking()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 275, in initialize_tracking
active_user.initialize()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 51, in initialize
cookie = self.get_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 71, in get_cookie
user = self.set_cookie()
File "/usr/local/lib/python3.7/site-packages/dbt/tracking.py", line 62, in set_cookie
dbt.clients.system.make_directory(cookie_dir)
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 85, in make_directory
raise e
File "/usr/local/lib/python3.7/site-packages/dbt/clients/system.py", line 79, in make_directory
os.makedirs(path)
File "/usr/local/lib/python3.7/os.py", line 221, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.dbt'

# Fixed code
def initialize_tracking(cookie_dir):
    global active_user
    active_user = User(cookie_dir)
    try:
        active_user.initialize()
    except Exception:
        logger.debug("Got an exception trying to initialize tracking", exc_info=True)
        active_user = User(None)
# Buggy code
def get_catalog(cls, profile, project_cfg, manifest):
    try:
        table = cls.run_operation(
            profile, project_cfg, manifest, GET_CATALOG_OPERATION_NAME
        )
    finally:
        cls.release_connection(profile, GET_CATALOG_OPERATION_NAME)

    schemas = list({node.schema.lower() for node in manifest.nodes.values()})

    results = table.where(lambda r: r["table_schema"].lower() in schemas)
    return results


# Traceback (AttributeError)
from svv_table_info
DEBUG:dbt:SQL status: SELECT in 2.90 seconds
DEBUG:dbt:On get_catalog_data: ROLLBACK
DEBUG:dbt:Flushing usage events
Encountered an error:
INFO:dbt:Encountered an error:
'NoneType' object has no attribute 'lower'
INFO:dbt:'NoneType' object has no attribute 'lower'
DEBUG:dbt:Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dbt/main.py", line 72, in main
results, succeeded = handle_and_check(args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dbt/main.py", line 117, in handle_and_check
task, res = run_from_args(parsed)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dbt/main.py", line 172, in run_from_args
results = run_from_task(task, proj, parsed)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dbt/main.py", line 180, in run_from_task
result = task.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dbt/task/generate.py", line 217, in run
results = adapter.get_catalog(profile, self.project.cfg, manifest)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dbt/adapters/default/impl.py", line 838, in get_catalog
results = table.where(lambda r: r['table_schema'].lower() in schemas)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/agate/table/where.py", line 25, in where
if test(row):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dbt/adapters/default/impl.py", line 838, in <lambda>
results = table.where(lambda r: r['table_schema'].lower() in schemas)
AttributeError: 'NoneType' object has no attribute 'lower'

# Fixed code
def get_catalog(cls, profile, project_cfg, manifest):
    try:
        table = cls.run_operation(
            profile, project_cfg, manifest, GET_CATALOG_OPERATION_NAME
        )
    finally:
        cls.release_connection(profile, GET_CATALOG_OPERATION_NAME)

    results = table.where(_filter_schemas(manifest))
    return results
# Buggy code
def print_start_line(node, schema_name, index, total):
    if node.get("resource_type") == NodeType.Model:
        print_model_start_line(node, schema_name, index, total)
    if node.get("resource_type") == NodeType.Test:
        print_test_start_line(node, schema_name, index, total)


# Traceback (psycopg2.NotSupportedError)
(venv)Tristans-MacBook-Pro:analytics tristan$ dbt archive
Traceback (most recent call last):
File "/Users/tristan/dev/venv/bin/dbt", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/Users/tristan/dev/dbt/scripts/dbt", line 8, in <module>
dbt.main.main(sys.argv[1:])
File "/Users/tristan/dev/dbt/dbt/main.py", line 38, in main
return handle(args)
File "/Users/tristan/dev/dbt/dbt/main.py", line 52, in handle
res = run_from_args(parsed)
File "/Users/tristan/dev/dbt/dbt/main.py", line 85, in run_from_args
return task.run()
File "/Users/tristan/dev/dbt/dbt/task/archive.py", line 19, in run
self.compile()
File "/Users/tristan/dev/dbt/dbt/task/archive.py", line 15, in compile
compiled = compiler.compile_archives()
File "/Users/tristan/dev/dbt/dbt/compilation.py", line 412, in compile_archives
sql = archive.compile()
File "/Users/tristan/dev/dbt/dbt/model.py", line 705, in compile
query = archival.compile()
File "/Users/tristan/dev/dbt/dbt/archival.py", line 41, in compile
self.schema.create_table(target_schema, target_table, dest_columns, sort=updated_at, dist=unique_key)
File "/Users/tristan/dev/dbt/dbt/schema.py", line 257, in create_table
self.execute_and_handle_permissions(sql, table)
File "/Users/tristan/dev/dbt/dbt/schema.py", line 159, in execute_and_handle_permissions
return self.execute(query)
File "/Users/tristan/dev/dbt/dbt/schema.py", line 137, in execute
raise e
File "/Users/tristan/dev/dbt/dbt/schema.py", line 129, in execute
cursor.execute(sql)
psycopg2.NotSupportedError: column "_sdc_source_key__id || '|' || _sdc_level_0_id" specified as distkey/sortkey is not in the table "mongo.accounts__duplicate_authors"

# Fixed code
def print_start_line(node, schema_name, index, total):
    if node.get("resource_type") == NodeType.Model:
        print_model_start_line(node, schema_name, index, total)
    if node.get("resource_type") == NodeType.Test:
        print_test_start_line(node, schema_name, index, total)
    if node.get("resource_type") == NodeType.Archive:
        print_archive_start_line(node, index, total)
# Buggy code
def print_result_line(result, schema_name, index, total):
    node = result.node

    if node.get("resource_type") == NodeType.Model:
        print_model_result_line(result, schema_name, index, total)
    elif node.get("resource_type") == NodeType.Test:
        print_test_result_line(result, schema_name, index, total)


# Traceback (psycopg2.NotSupportedError)
(venv)Tristans-MacBook-Pro:analytics tristan$ dbt archive
Traceback (most recent call last):
File "/Users/tristan/dev/venv/bin/dbt", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/Users/tristan/dev/dbt/scripts/dbt", line 8, in <module>
dbt.main.main(sys.argv[1:])
File "/Users/tristan/dev/dbt/dbt/main.py", line 38, in main
return handle(args)
File "/Users/tristan/dev/dbt/dbt/main.py", line 52, in handle
res = run_from_args(parsed)
File "/Users/tristan/dev/dbt/dbt/main.py", line 85, in run_from_args
return task.run()
File "/Users/tristan/dev/dbt/dbt/task/archive.py", line 19, in run
self.compile()
File "/Users/tristan/dev/dbt/dbt/task/archive.py", line 15, in compile
compiled = compiler.compile_archives()
File "/Users/tristan/dev/dbt/dbt/compilation.py", line 412, in compile_archives
sql = archive.compile()
File "/Users/tristan/dev/dbt/dbt/model.py", line 705, in compile
query = archival.compile()
File "/Users/tristan/dev/dbt/dbt/archival.py", line 41, in compile
self.schema.create_table(target_schema, target_table, dest_columns, sort=updated_at, dist=unique_key)
File "/Users/tristan/dev/dbt/dbt/schema.py", line 257, in create_table
self.execute_and_handle_permissions(sql, table)
File "/Users/tristan/dev/dbt/dbt/schema.py", line 159, in execute_and_handle_permissions
return self.execute(query)
File "/Users/tristan/dev/dbt/dbt/schema.py", line 137, in execute
raise e
File "/Users/tristan/dev/dbt/dbt/schema.py", line 129, in execute
cursor.execute(sql)
psycopg2.NotSupportedError: column "_sdc_source_key__id || '|' || _sdc_level_0_id" specified as distkey/sortkey is not in the table "mongo.accounts__duplicate_authors"

# Fixed code
def print_result_line(result, schema_name, index, total):
    node = result.node

    if node.get("resource_type") == NodeType.Model:
        print_model_result_line(result, schema_name, index, total)
    elif node.get("resource_type") == NodeType.Test:
        print_test_result_line(result, schema_name, index, total)
    elif node.get("resource_type") == NodeType.Archive:
        print_archive_result_line(result, index, total)
# Buggy code
def do_compile(self):
    schema_tests = []
    for model_name, constraint_blob in self.schema.items():
        constraints = constraint_blob.get("constraints", {})
        for constraint_type, constraint_data in constraints.items():
            for params in constraint_data:
                schema_test_klass = self.get_test(constraint_type)
                schema_test = schema_test_klass(
                    self.project,
                    self.og_target_dir,
                    self.rel_filepath,
                    model_name,
                    params,
                )
                schema_tests.append(schema_test)
    return schema_tests


# Traceback (TypeError)
Traceback (most recent call last):
File "/Users/tristan/dev/venv/bin/dbt", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/Users/tristan/dev/dbt/scripts/dbt", line 8, in <module>
dbt.main.main(sys.argv[1:])
File "/Users/tristan/dev/dbt/dbt/main.py", line 41, in main
handle(args)
File "/Users/tristan/dev/dbt/dbt/main.py", line 143, in handle
task.run()
File "/Users/tristan/dev/dbt/dbt/task/run.py", line 28, in run
graph_type = self.compile()
File "/Users/tristan/dev/dbt/dbt/task/run.py", line 20, in compile
results = compiler.compile(self.args.dry)
File "/Users/tristan/dev/dbt/dbt/compilation.py", line 399, in compile
written_schema_tests = self.compile_schema_tests(linker)
File "/Users/tristan/dev/dbt/dbt/compilation.py", line 324, in compile_schema_tests
schema_tests.extend(schema.compile()) # compiling a SchemaFile returns >= 0 SchemaTest models
File "/Users/tristan/dev/dbt/dbt/model.py", line 556, in compile
for params in constraint_data:
TypeError: 'NoneType' object is not iterable

# Fixed code
def do_compile(self):
    schema_tests = []
    for model_name, constraint_blob in self.schema.items():
        constraints = constraint_blob.get("constraints", {})
        for constraint_type, constraint_data in constraints.items():
            if constraint_data is None:
                compiler_error(
                    self,
                    "no constraints given to test: '{}.{}'".format(
                        model_name, constraint_type
                    ),
                )
            for params in constraint_data:
                schema_test_klass = self.get_test(constraint_type)
                schema_test = schema_test_klass(
                    self.project,
                    self.og_target_dir,
                    self.rel_filepath,
                    model_name,
                    params,
                )
                schema_tests.append(schema_test)
    return schema_tests
# Buggy code
def finalizetempoutputfile(self, options, outputfile, fulloutputpath):
    """Write the temp outputfile to its final destination."""
    outputfile.reset()
    outputstring = outputfile.read()
    outputfile = self.openoutputfile(options, fulloutputpath)
    outputfile.write(outputstring)
    outputfile.close()


# Traceback (AttributeError)
$ pot2po --errorlevel=traceback -t af templates af
pot2po: WARNING: writing to temporary output... 9%
pot2po: WARNING: Error processing: input templates/browser/chrome/overrides/appstrings.properties.pot, output af/browser/chrome/overrides/appstrings.properties.po, template af/browser/chrome/overrides/appstrings.properties.po: Traceback (most recent call last):

File "/Users/dwayne/dev/toolkit/translate/misc/optrecurse.py", line 508, in recursiveprocess
fulltemplatepath)

File "/Users/dwayne/dev/toolkit/translate/convert/convert.py", line 179, in processfile
fulltemplatepath)

File "/Users/dwayne/dev/toolkit/translate/misc/optrecurse.py", line 568, in processfile
fulloutputpath)

File "/Users/dwayne/dev/toolkit/translate/misc/optrecurse.py", line 535, in finalizetempoutputfile
outputfile.reset()

AttributeError: '_io.BytesIO' object has no attribute 'reset'

# Fixed code
def finalizetempoutputfile(self, options, outputfile, fulloutputpath):
    """Write the temp outputfile to its final destination."""
    outputfile.seek(0, 0)
    outputstring = outputfile.read()
    outputfile = self.openoutputfile(options, fulloutputpath)
    outputfile.write(outputstring)
    outputfile.close()
# Buggy code
def __init__(self, coordinates=None):
    """
    Parameters
    ----------
    coordinates : sequence
        A sequence of (x, y [,z]) numeric coordinate pairs or triples

    Rings are implicitly closed. There is no need to specific a final
    coordinate pair identical to the first.

    Example
    -------
    Construct a square ring.

      >>> ring = LinearRing( ((0, 0), (0, 1), (1 ,1 ), (1 , 0)) )
      >>> ring.is_closed
      True
      >>> ring.length
      4.0
    """
    BaseGeometry.__init__(self)
    if coordinates is not None:
        self._set_coords(coordinates)


# Traceback (AttributeError)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\Miniconda3\lib\site-packages\shapely\speedups\_speedups.pyx in shapely.speedups._speedups.geos_linearring_from_py()

AttributeError: 'list' object has no attribute '__array_interface__'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-35-4b345c8069dd> in <module>()
----> 1 print(Polygon(points_list))

~\Miniconda3\lib\site-packages\shapely\geometry\polygon.py in __init__(self, shell, holes)
238
239         if shell is not None:
--> 240             ret = geos_polygon_from_py(shell, holes)
241             if ret is not None:
242                 self._geom, self._ndim = ret

~\Miniconda3\lib\site-packages\shapely\geometry\polygon.py in geos_polygon_from_py(shell, holes)
492
493     if shell is not None:
--> 494         ret = geos_linearring_from_py(shell)
495         if ret is None:
496             return None

~\Miniconda3\lib\site-packages\shapely\speedups\_speedups.pyx in shapely.speedups._speedups.geos_linearring_from_py()

TypeError: object of type 'Point' has no len()

# Fixed code
def __init__(self, coordinates=None):
    """
    Parameters
    ----------
    coordinates : sequence
        A sequence of (x, y [,z]) numeric coordinate pairs or triples.
        Also can be a sequence of Point objects.

    Rings are implicitly closed. There is no need to specific a final
    coordinate pair identical to the first.

    Example
    -------
    Construct a square ring.

      >>> ring = LinearRing( ((0, 0), (0, 1), (1 ,1 ), (1 , 0)) )
      >>> ring.is_closed
      True
      >>> ring.length
      4.0
    """
    BaseGeometry.__init__(self)
    if coordinates is not None:
        self._set_coords(coordinates)
# Buggy code
def __init__(self, shell=None, holes=None):
    """
    Parameters
    ----------
    shell : sequence
        A sequence of (x, y [,z]) numeric coordinate pairs or triples
    holes : sequence
        A sequence of objects which satisfy the same requirements as the
        shell parameters above

    Example
    -------
    Create a square polygon with no holes

      >>> coords = ((0., 0.), (0., 1.), (1., 1.), (1., 0.), (0., 0.))
      >>> polygon = Polygon(coords)
      >>> polygon.area
      1.0
    """
    BaseGeometry.__init__(self)

    if shell is not None:
        ret = geos_polygon_from_py(shell, holes)
        if ret is not None:
            self._geom, self._ndim = ret
        else:
            self.empty()


# Traceback (AttributeError)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\Miniconda3\lib\site-packages\shapely\speedups\_speedups.pyx in shapely.speedups._speedups.geos_linearring_from_py()

AttributeError: 'list' object has no attribute '__array_interface__'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-35-4b345c8069dd> in <module>()
----> 1 print(Polygon(points_list))

~\Miniconda3\lib\site-packages\shapely\geometry\polygon.py in __init__(self, shell, holes)
238
239         if shell is not None:
--> 240             ret = geos_polygon_from_py(shell, holes)
241             if ret is not None:
242                 self._geom, self._ndim = ret

~\Miniconda3\lib\site-packages\shapely\geometry\polygon.py in geos_polygon_from_py(shell, holes)
492
493     if shell is not None:
--> 494         ret = geos_linearring_from_py(shell)
495         if ret is None:
496             return None

~\Miniconda3\lib\site-packages\shapely\speedups\_speedups.pyx in shapely.speedups._speedups.geos_linearring_from_py()

TypeError: object of type 'Point' has no len()

# Fixed code
def __init__(self, shell=None, holes=None):
    """
    Parameters
    ----------
    shell : sequence
        A sequence of (x, y [,z]) numeric coordinate pairs or triples.
        Also can be a sequence of Point objects.
    holes : sequence
        A sequence of objects which satisfy the same requirements as the
        shell parameters above

    Example
    -------
    Create a square polygon with no holes

      >>> coords = ((0., 0.), (0., 1.), (1., 1.), (1., 0.), (0., 0.))
      >>> polygon = Polygon(coords)
      >>> polygon.area
      1.0
    """
    BaseGeometry.__init__(self)

    if shell is not None:
        ret = geos_polygon_from_py(shell, holes)
        if ret is not None:
            self._geom, self._ndim = ret
        else:
            self.empty()