gurudesh/pytracebugs huggingface dataset:
# Buggy code
def bounds(self):
    xy = self.coords[0]
    return (xy[0], xy[1], xy[0], xy[1])


# Traceback (IndexError)
In [51]: Point().bounds
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-51-6ed8561bf72c> in <module>
----> 1 Point().bounds

~/miniconda3/envs/dev37/lib/python3.7/site-packages/shapely/geometry/point.py in bounds(self)
120     @property
121     def bounds(self):
--> 122         xy = self.coords[0]
123         return (xy[0], xy[1], xy[0], xy[1])
124

IndexError: list index out of range

# Fixed code
def bounds(self):
    """Returns minimum bounding region (minx, miny, maxx, maxy)"""
    try:
        xy = self.coords[0]
    except IndexError:
        return ()
    return (xy[0], xy[1], xy[0], xy[1])
# Buggy code
def _geom(self):
    """Keeps the GEOS geometry in synch with the context."""
    gtag = self.gtag()
    if gtag != self._gtag or self._is_empty:
        self.empty()
        self.__geom__, n = self.factory(self.context)
    self._gtag = gtag
    return self.__geom__


# Traceback (AssertionError)
Python 3.6.2 (default, Aug  7 2017, 17:26:39)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import shapely
shapely.__version__
'1.6.2.post1'
from shapely import geometry
empty_mp = geometry.MultiPolygon()
empty_mp.is_empty
True
empty_json = geometry.mapping(empty_mp)
print(empty_json)
{'type': 'MultiPolygon', 'coordinates': []}
empty_shape = geometry.shape(empty_json)
empty_shape.is_empty
True
empty_asShape = geometry.asShape(empty_json)
empty_asShape.is_empty
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/python-3.6/lib/python3.6/site-packages/shapely/geometry/base.py", line 643, in is_empty
return (self._geom is None) or bool(self.impl['is_empty'](self))
File "/opt/python-3.6/lib/python3.6/site-packages/shapely/geometry/proxy.py", line 33, in _geom
self.__geom__, n = self.factory(self.context)
File "/opt/python-3.6/lib/python3.6/site-packages/shapely/geometry/multipolygon.py", line 136, in geos_multipolygon_from_py
assert L >= 1
AssertionError


# Fixed code
def _geom(self):
    """Keeps the GEOS geometry in synch with the context."""
    gtag = self.gtag()
    if gtag != self._gtag or self._is_empty:
        self.empty()
        if len(self.context) > 0:
            self.__geom__, n = self.factory(self.context)
    self._gtag = gtag
    return self.__geom__
# Buggy code
def __geo_interface__(self):
    coords = [tuple(self.exterior.coords)]
    for hole in self.interiors:
        coords.append(tuple(hole.coords))
    return {"type": "Polygon", "coordinates": tuple(coords)}


# Traceback (AttributeError)
import shapely
from shapely import wkt

shapely.__version__
'1.5.17'

pg = wkt.loads('POLYGON EMPTY')
pg.wkt
'POLYGON EMPTY'
pg.__geo_interface__
Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\ArcGIS10.5\lib\site-packages\shapely\geometry\polygon.py", line 300, in __geo_interface__
coords = [tuple(self.exterior.coords)]
AttributeError: 'NoneType' object has no attribute 'coords'


# Fixed code
def __geo_interface__(self):
    if not self.exterior:
        coords = []
    else:
        coords = [tuple(self.exterior.coords)]
        for hole in self.interiors:
            coords.append(tuple(hole.coords))
    return {"type": "Polygon", "coordinates": tuple(coords)}
# Buggy code
def array_interface(self):
    """Provide the Numpy array protocol."""
    return self.coords.array_interface()


# Traceback (TypeError)
Point().__array_interface__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/snorf/Desktop/Shapely/shapely/geometry/point.py", line 112, in array_interface
ai = self.array_interface_base
File "/Users/snorf/Desktop/Shapely/shapely/geometry/base.py", line 299, in array_interface_base
'data': self.ctypes,
File "/Users/snorf/Desktop/Shapely/shapely/geometry/point.py", line 100, in ctypes
array_type = c_double * self._ndim
TypeError: can't multiply sequence by non-int of type 'NoneType'

# Fixed code
def array_interface(self):
    """Provide the Numpy array protocol."""
    if self.is_empty:
        ai = {"version": 3, "typestr": "<f8", "shape": (0,), "data": (c_double * 0)()}
    else:
        ai = self.coords.array_interface()
    return ai
# Buggy code
def array_interface(self):
    """Provide the Numpy array protocol."""
    ai = self.array_interface_base
    ai.update({"shape": (self._ndim,)})
    return ai


# Traceback (TypeError)
Point().__array_interface__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/snorf/Desktop/Shapely/shapely/geometry/point.py", line 112, in array_interface
ai = self.array_interface_base
File "/Users/snorf/Desktop/Shapely/shapely/geometry/base.py", line 299, in array_interface_base
'data': self.ctypes,
File "/Users/snorf/Desktop/Shapely/shapely/geometry/point.py", line 100, in ctypes
array_type = c_double * self._ndim
TypeError: can't multiply sequence by non-int of type 'NoneType'

# Fixed code
def array_interface(self):
    """Provide the Numpy array protocol."""
    if self.is_empty:
        ai = {"version": 3, "typestr": "<f8", "shape": (0,), "data": (c_double * 0)()}
    else:
        ai = self.array_interface_base
        ai.update({"shape": (self._ndim,)})
    return ai
# Buggy code
def __init__(self, dll):
    super(LGEOS330, self).__init__(dll)

    # GEOS 3.3.8 from homebrew has, but doesn't advertise
    # GEOSPolygonize_full. We patch it in explicitly here.
    key = "GEOSPolygonize_full"
    func = getattr(self._lgeos, key + "_r")
    attr = ftools.partial(func, self.geos_handle)
    attr.__name__ = func.__name__
    setattr(self, key, attr)

    self.methods["unary_union"] = self.GEOSUnaryUnion
    self.methods["cascaded_union"] = self.methods["unary_union"]


# Traceback (AttributeError)
$ python -c "import shapely.geos"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/openerp/europortetest/railfleetng/ve/local/lib/python2.7/site-packages/shapely/geos.py", line 133, in <module>
prototype(_lgeos, geos_version)
File "/home/openerp/europortetest/railfleetng/ve/local/lib/python2.7/site-packages/shapely/ctypes_declarations.py", line 279, in prototype
lgeos.GEOSisClosed.restype = c_byte
File "/usr/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/libgeos_c.so.1: undefined symbol: GEOSisClosed

# Fixed code
def __init__(self, dll):
    super(LGEOS330, self).__init__(dll)

    # GEOS 3.3.8 from homebrew has, but doesn't advertise
    # GEOSPolygonize_full. We patch it in explicitly here.
    key = "GEOSPolygonize_full"
    func = getattr(self._lgeos, key + "_r")
    attr = ftools.partial(func, self.geos_handle)
    attr.__name__ = func.__name__
    setattr(self, key, attr)

    for pred in (self.GEOSisClosed,):
        pred.func.errcheck = errcheck_predicate

    self.methods["unary_union"] = self.GEOSUnaryUnion
    self.methods["is_closed"] = self.GEOSisClosed
    self.methods["cascaded_union"] = self.methods["unary_union"]
# Buggy code
def cleanup():
    lgeos.__del__()


# Traceback (AttributeError)
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/opt/python-2.7.6/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/kwilcox/.virtualenvs/larvamap/lib/python2.7/site-packages/shapely/geos.py", line 729, in cleanup
lgeos.__del__()
AttributeError: 'NoneType' object has no attribute '__del__'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/opt/python-2.7.6/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/kwilcox/.virtualenvs/larvamap/lib/python2.7/site-packages/shapely/geos.py", line 729, in cleanup
lgeos.__del__()
AttributeError: 'NoneType' object has no attribute '__del__'

# Fixed code
def cleanup():
    del lgeos
# Buggy code
def __del__(self):
    """Cleanup GEOS related processes"""
    if self._lgeos is not None:
        self._lgeos.finishGEOS()
        self._lgeos = None
        self.geos_handle = None


# Traceback (AttributeError)
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/opt/python-2.7.6/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/kwilcox/.virtualenvs/larvamap/lib/python2.7/site-packages/shapely/geos.py", line 729, in cleanup
lgeos.__del__()
AttributeError: 'NoneType' object has no attribute '__del__'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/opt/python-2.7.6/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/kwilcox/.virtualenvs/larvamap/lib/python2.7/site-packages/shapely/geos.py", line 729, in cleanup
lgeos.__del__()
AttributeError: 'NoneType' object has no attribute '__del__'

# Fixed code
def __del__(self):
    """Cleanup GEOS related processes"""
    if self._lgeos is not None:
        self._lgeos.finishGEOS()
        self._lgeos = None
        self.geos_handle = None
    LOG.debug("GEOS Finished")
# Buggy code
def cleanup():
    del lgeos


# Traceback (AttributeError)
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/opt/python-2.7.6/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/kwilcox/.virtualenvs/larvamap/lib/python2.7/site-packages/shapely/geos.py", line 729, in cleanup
lgeos.__del__()
AttributeError: 'NoneType' object has no attribute '__del__'
Error in sys.exitfunc:
Traceback (most recent call last):
File "/opt/python-2.7.6/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/kwilcox/.virtualenvs/larvamap/lib/python2.7/site-packages/shapely/geos.py", line 729, in cleanup
lgeos.__del__()
AttributeError: 'NoneType' object has no attribute '__del__'

# Fixed code
def cleanup(proxy):
    del proxy
# Buggy code
def get_node_group(node):
    node_type = "exploited" if node.get("exploited") else "clean"
    node_os = NodeService.get_node_os(node)
    return "%s_%s" % (node_type, node_os)


# Traceback (OSError)
2020-01-17 10:14:45,982 - iostream.py:1518 - _do_ssl_handshake() - WARNING - SSL Error on 1504 ('1.1.1.2', 4469): [SSL: NO_SHARED_CIPHER] no shared cipher (_ssl.c:1076)
2020-01-17 10:14:46,055 - iostream.py:1518 - _do_ssl_handshake() - WARNING - SSL Error on 1500 ('1.1.1.2', 4470): [SSL: VERSION_TOO_LOW] version too low (_ssl.c:1076)
2020-01-17 10:14:46,136 - iostream.py:744 - _handle_events() - ERROR - Uncaught exception, closing connection.
Traceback (most recent call last):
File "C:\Users\Vakaris\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\iostream.py", line 709, in _handle_events
self._handle_read()
File "C:\Users\Vakaris\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\iostream.py", line 1581, in _handle_read
self._do_ssl_handshake()
File "C:\Users\Vakaris\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\iostream.py", line 1501, in _do_ssl_handshake
self.socket.do_handshake()
File "C:\Users\Vakaris\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
OSError: [Errno 0] Error
2020-01-17 10:14:46,163 - base_events.py:1604 - default_exception_handler() - ERROR - Exception in callback None()
handle: <Handle cancelled>
Traceback (most recent call last):
File "C:\Users\Vakaris\AppData\Local\Programs\Python\Python37\lib\asyncio\events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "C:\Users\Vakaris\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\platform\asyncio.py", line 122, in _handle_events
handler_func(fileobj, events)
File "C:\Users\Vakaris\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\stack_context.py", line 300, in null_wrapper
return fn(*args, **kwargs)
File "C:\Users\Vakaris\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\iostream.py", line 709, in _handle_events
self._handle_read()
File "C:\Users\Vakaris\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\iostream.py", line 1581, in _handle_read
self._do_ssl_handshake()
File "C:\Users\Vakaris\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\iostream.py", line 1501, in _do_ssl_handshake
self.socket.do_handshake()
File "C:\Users\Vakaris\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
OSError: [Errno 0] Error

# Fixed code
def get_node_group(node) -> str:
    if "group" in node and node["group"]:
        return node["group"]
    node_type = "exploited" if node.get("exploited") else "clean"
    node_os = NodeService.get_node_os(node)
    return NodeStates.get_by_keywords([node_type, node_os]).value
# Buggy code
def process_system_info_telemetry(telemetry_json):
    process_ssh_info(telemetry_json)
    process_credential_info(telemetry_json)
    process_mimikatz_and_wmi_info(telemetry_json)
    process_aws_data(telemetry_json)
    update_db_with_new_hostname(telemetry_json)
    test_antivirus_existence(telemetry_json)


# Traceback (KeyError)
2019-10-11 19:36:09,431 - processing.py:29 - process_telemetry() - ERROR - Exception caught while processing telemetry. Info: _id
Traceback (most recent call last):
File "C:\Users\shay.nehmad\PycharmProjects\monkey\monkey\monkey_island\cc\services\telemetry\processing\processing.py", line 25, in process_telemetry
TELEMETRY_CATEGORY_TO_PROCESSING_FUNC[telem_category](telemetry_json)
File "C:\Users\shay.nehmad\PycharmProjects\monkey\monkey\monkey_island\cc\services\telemetry\processing\system_info.py", line 16, in process_system_info_telemetry
update_db_with_new_hostname(telemetry_json)
File "C:\Users\shay.nehmad\PycharmProjects\monkey\monkey\monkey_island\cc\services\telemetry\processing\system_info.py", line 105, in update_db_with_new_hostname
Monkey.get_single_monkey_by_id(telemetry_json['_id']).set_hostname(telemetry_json['data']['hostname'])
KeyError: '_id'

# Fixed code
def process_system_info_telemetry(telemetry_json):
    telemetry_processing_stages = [
        process_ssh_info,
        process_credential_info,
        process_mimikatz_and_wmi_info,
        process_aws_data,
        update_db_with_new_hostname,
        test_antivirus_existence,
    ]

    # Calling safe_process_telemetry so if one of the stages fail, we log and move on instead of failing the rest of
    # them, as they are independent.
    for stage in telemetry_processing_stages:
        safe_process_telemetry(stage, telemetry_json)
# Buggy code
def update_db_with_new_hostname(telemetry_json):
    Monkey.get_single_monkey_by_id(telemetry_json["_id"]).set_hostname(
        telemetry_json["data"]["hostname"]
    )


# Traceback (KeyError)
2019-10-11 19:36:09,431 - processing.py:29 - process_telemetry() - ERROR - Exception caught while processing telemetry. Info: _id
Traceback (most recent call last):
File "C:\Users\shay.nehmad\PycharmProjects\monkey\monkey\monkey_island\cc\services\telemetry\processing\processing.py", line 25, in process_telemetry
TELEMETRY_CATEGORY_TO_PROCESSING_FUNC[telem_category](telemetry_json)
File "C:\Users\shay.nehmad\PycharmProjects\monkey\monkey\monkey_island\cc\services\telemetry\processing\system_info.py", line 16, in process_system_info_telemetry
update_db_with_new_hostname(telemetry_json)
File "C:\Users\shay.nehmad\PycharmProjects\monkey\monkey\monkey_island\cc\services\telemetry\processing\system_info.py", line 105, in update_db_with_new_hostname
Monkey.get_single_monkey_by_id(telemetry_json['_id']).set_hostname(telemetry_json['data']['hostname'])
KeyError: '_id'

# Fixed code
def update_db_with_new_hostname(telemetry_json):
    Monkey.get_single_monkey_by_guid(telemetry_json["monkey_guid"]).set_hostname(
        telemetry_json["data"]["hostname"]
    )
# Buggy code
def is_64bit_windows_os():
    """
    Checks for 64 bit Windows OS using environment variables.
    :return:
    """
    return "PROGRAMFILES(X86)" in os.environ


# Traceback (WindowsError)
2019-06-12 10:19:04,545 [24008:17700:ERROR] main.main.130: Exception thrown from monkey's start function
Traceback (most recent call last):
File "monkey\infection_monkey\main.py", line 121, in main
File "monkey\infection_monkey\monkey.py", line 83, in start
File "monkey\infection_monkey\utils.py", line 46, in create_monkey_dir
WindowsError: [Error 5] Access is denied: 'C:\\Windows\\Temp\\monkey_dir'

# Fixed code
def is_64bit_windows_os():
    """
    Checks for 64 bit Windows OS using environment variables.
    """
    return "PROGRAMFILES(X86)" in os.environ
# Buggy code
def get_monkey_dir_path():
    if is_windows_os():
        return WormConfiguration.monkey_dir_windows
    else:
        return WormConfiguration.monkey_dir_linux


# Traceback (WindowsError)
2019-06-12 10:19:04,545 [24008:17700:ERROR] main.main.130: Exception thrown from monkey's start function
Traceback (most recent call last):
File "monkey\infection_monkey\main.py", line 121, in main
File "monkey\infection_monkey\monkey.py", line 83, in start
File "monkey\infection_monkey\utils.py", line 46, in create_monkey_dir
WindowsError: [Error 5] Access is denied: 'C:\\Windows\\Temp\\monkey_dir'

# Fixed code
def get_monkey_dir_path():
    return os.path.join(tempfile.gettempdir(), WormConfiguration.monkey_dir_name)
# Buggy code
def _show_text_with_options(self, cc, pl, text, text_x, text_y):
    cc.move_to(text_x, text_y)
    pl.set_text(text)
    PangoCairo.update_layout(cc, pl)
    PangoCairo.show_layout(cc, pl)


# Traceback (TypeError)
Traceback (most recent call last):
File "/usr/share/drawing/drawing/tool_text.py", line 184, in _preview_text
self.do_tool_operation(operation)
File "/usr/share/drawing/drawing/tool_text.py", line 251, in do_tool_operation
entire_text, text_x + dx, text_y + dy)
File "/usr/share/drawing/drawing/tool_text.py", line 264, in _show_text_with_options
pl.set_text(text)
TypeError: Pango.Layout.set_text() takes exactly 3 arguments (2 given)

# Fixed code
def _show_text_with_options(self, cc, pl, text, text_x, text_y):
    cc.move_to(text_x, text_y)
    pl.set_text(text, -1)
    PangoCairo.update_layout(cc, pl)
    PangoCairo.show_layout(cc, pl)
# Buggy code
def _set_active_type(self, *args):
    state_as_string = self.get_option_value("filters_type")
    self._reset_type_values()
    if state_as_string == "blur_fast":
        self.blur_algo = BlurType.CAIRO_REPAINTS
        self.type_label = _("Fast blur")
    elif state_as_string == "blur_slow":
        self.blur_algo = BlurType.PX_BOX
        self.type_label = _("Slow blur")
    elif state_as_string == "tiles":
        self.blur_algo = BlurType.TILES
        self.type_label = _("Pixelation")
    elif state_as_string == "saturation":
        self.saturate = True
        self.type_label = _("Change saturation")
    elif state_as_string == "veil":
        self.pixelate = True
        self.type_label = _("Veil")
    elif state_as_string == "invert":
        self.invert = True
        self.type_label = _("Invert colors")
    elif state_as_string == "transparency":
        self.transparency = True
        self.type_label = _("Add transparency")
    else:
        self.type_label = _("Select a filter…")
    self.bar.on_filter_changed()


# Traceback (TypeError)
Traceback (most recent call last):
File "/usr/share/drawing/drawing/tool_text.py", line 184, in _preview_text
self.do_tool_operation(operation)
File "/usr/share/drawing/drawing/tool_text.py", line 251, in do_tool_operation
entire_text, text_x + dx, text_y + dy)
File "/usr/share/drawing/drawing/tool_text.py", line 264, in _show_text_with_options
pl.set_text(text)
TypeError: Pango.Layout.set_text() takes exactly 3 arguments (2 given)

# Fixed code
def _set_active_type(self, *args):
    state_as_string = self.get_option_value("filters_type")
    self._reset_type_values()
    if state_as_string == "blur_fast":
        self.blur_algo = BlurType.CAIRO_REPAINTS
        self.type_label = _("Fast blur")
    elif state_as_string == "blur_slow":
        self.blur_algo = BlurType.PX_BOX
        self.type_label = _("Slow blur")
    elif state_as_string == "tiles":
        self.blur_algo = BlurType.TILES
        self.type_label = _("Pixelization")
    elif state_as_string == "saturation":
        self.saturate = True
        self.type_label = _("Change saturation")
    elif state_as_string == "veil":
        self.pixelate = True
        self.type_label = _("Veil")
    elif state_as_string == "invert":
        self.invert = True
        self.type_label = _("Invert colors")
    elif state_as_string == "transparency":
        self.transparency = True
        self.type_label = _("Add transparency")
    else:
        self.type_label = _("Select a filter…")
    self.bar.on_filter_changed()
# Buggy code
def set_tools_labels_visibility(self, visible):
    """Change the way tools are displayed in the side panel. Visible labels
    mean the tools will be arranged in a scrollable list of buttons, else
    they will be in an adaptative flowbox."""
    for tool_id in self.tools:
        self.tools[tool_id].label_widget.set_visible(visible)
    nb_tools = len(self.tools)
    if visible:
        if self.tools_panel.get_parent() is self.tools_nonscrollable_box:
            self.tools_nonscrollable_box.remove(self.tools_panel)
            self.tools_scrollable_box.add(self.tools_panel)
        self.tools_panel.set_min_children_per_line(nb_tools)
    else:
        if self.tools_panel.get_parent() is self.tools_scrollable_box:
            self.tools_scrollable_box.remove(self.tools_panel)
            self.tools_nonscrollable_box.add(self.tools_panel)
            # FIXME largeur des boutons pétée
        nb_tools = len(self.tools)
        self.tools_panel.set_min_children_per_line((nb_tools + (nb_tools % 3)) / 3)
    self.tools_panel.set_max_children_per_line(nb_tools)


# Traceback (AttributeError)
Traceback (most recent call last):
File "/usr/bin/drawing", line 42, in <module>
from drawing import main
File "/usr/share/drawing/drawing/main.py", line 23, in <module>
from .window import DrawingWindow
File "/usr/share/drawing/drawing/window.py", line 40, in <module>
from .image import DrawingImage
File "/usr/share/drawing/drawing/image.py", line 31, in <module>
@Gtk.Template(resource_path='/com/github/maoschanz/drawing/ui/image.ui')
File "/usr/lib/python3/dist-packages/gi/overrides/__init__.py", line 39, in __getattr__
return getattr(self._introspection_module, name)
File "/usr/lib/python3/dist-packages/gi/module.py", line 137, in __getattr__
self.__name__, name))
AttributeError: 'gi.repository.Gtk' object has no attribute 'Template'

# Fixed code
def set_tools_labels_visibility(self, visible):
    """Change the way tools are displayed in the side panel. Visible labels
    mean the tools will be arranged in a scrollable list of buttons, else
    they will be in an adaptative flowbox."""
    for tool_id in self.tools:
        self.tools[tool_id].label_widget.set_visible(visible)
    nb_tools = len(self.tools)
    if visible:
        self.tools_panel.set_min_children_per_line(nb_tools)
        self.tools_nonscrollable_box.remove(self.tools_panel)
        self.tools_scrollable_box.add(self.tools_panel)
    else:
        self.tools_scrollable_box.remove(self.tools_panel)
        self.tools_nonscrollable_box.add(self.tools_panel)
        nb_min = int((nb_tools + (nb_tools % 3)) / 3) - 1
        self.tools_panel.set_min_children_per_line(nb_min)
    self.tools_panel.set_max_children_per_line(nb_tools)
# Buggy code
def set_compact(self, state):
    if state:
        self.main_menu_btn.set_menu_model(self.long_main_menu)
    else:
        self.main_menu_btn.set_menu_model(self.short_main_menu)
    self.save_label.set_visible(not state)
    self.save_icon.set_visible(state)
    self.hidable_widget.set_visible(not state)
    self.new_btn.set_visible(not state)
    self.is_narrow = state


# Traceback (AttributeError)
Traceback (most recent call last):
File "/usr/bin/drawing", line 42, in <module>
from drawing import main
File "/usr/share/drawing/drawing/main.py", line 23, in <module>
from .window import DrawingWindow
File "/usr/share/drawing/drawing/window.py", line 40, in <module>
from .image import DrawingImage
File "/usr/share/drawing/drawing/image.py", line 31, in <module>
@Gtk.Template(resource_path='/com/github/maoschanz/drawing/ui/image.ui')
File "/usr/lib/python3/dist-packages/gi/overrides/__init__.py", line 39, in __getattr__
return getattr(self._introspection_module, name)
File "/usr/lib/python3/dist-packages/gi/module.py", line 137, in __getattr__
self.__name__, name))
AttributeError: 'gi.repository.Gtk' object has no attribute 'Template'

# Fixed code
def set_compact(self, state):  # TODO state as an int
    if state:
        self.main_menu_btn.set_menu_model(self.long_main_menu)
    else:
        self.main_menu_btn.set_menu_model(self.short_main_menu)
    self.save_label.set_visible(not state)
    self.save_icon.set_visible(state)
    self.hidable_widget.set_visible(not state)
    self.new_btn.set_visible(not state)
    self.is_narrow = state
# Buggy code
def _get_mpi_implementation_flags():
    output = six.StringIO()
    command = "mpirun --version"
    try:
        exit_code = safe_shell_exec.execute(command, stdout=output, stderr=output)
        output_msg = output.getvalue()
    except Exception:
        print(traceback.format_exc(), file=sys.stderr)
        return None
    finally:
        output.close()

    if exit_code == 0:
        if "Open MPI" in output_msg:
            return list(_OMPI_FLAGS)
        elif "IBM Spectrum MPI" in output_msg:
            return list(_SMPI_FLAGS)
        elif "MPICH" in output_msg:
            return list(_MPICH_FLAGS)
        print(
            "Open MPI/Spectrum MPI/MPICH not found in output of mpirun --version.",
            file=sys.stderr,
        )
        return None
    else:
        print("Was not able to run %s:\n%s" % (command, output_msg), file=sys.stderr)
        return None


# Traceback (Exception)
horovodrun -np 1 -H localhost:1 python pytorch_mnist.py
Open MPI not found in output of mpirun --version.
Traceback (most recent call last):
File "/opt/conda/bin/horovodrun", line 21, in <module>
run.run()
File "/opt/conda/lib/python3.6/site-packages/horovod/run/run.py", line 448, in run
'horovodrun convenience script currently only supports '
Exception: horovodrun convenience script currently only supports Open MPI.

Choose one of:
1. Install Open MPI 4.0.0+ and re-install Horovod (use --no-cache-dir pip option).
2. Run distributed training script using the standard way provided by your MPI distribution (usually mpirun, srun, or jsrun).
root@3da487b92c3d:/horovod/examples# mpirun --version
mpirun.real (OpenRTE) 4.0.1

Report bugs to http://www.open-mpi.org/community/help/

# Fixed code
def _get_mpi_implementation_flags():
    output = six.StringIO()
    command = "mpirun --version"
    try:
        exit_code = safe_shell_exec.execute(command, stdout=output, stderr=output)
        output_msg = output.getvalue()
    except Exception:
        print(traceback.format_exc(), file=sys.stderr)
        return None
    finally:
        output.close()

    if exit_code == 0:
        if "Open MPI" in output_msg or "OpenRTE" in output_msg:
            return list(_OMPI_FLAGS)
        elif "IBM Spectrum MPI" in output_msg:
            return list(_SMPI_FLAGS)
        elif "MPICH" in output_msg:
            return list(_MPICH_FLAGS)
        print(
            "Open MPI/Spectrum MPI/MPICH not found in output of mpirun --version.",
            file=sys.stderr,
        )
        return None
    else:
        print("Was not able to run %s:\n%s" % (command, output_msg), file=sys.stderr)
        return None
# Buggy code
def _create_option_callback(index, option_key, option_tensor, dtype):
    def _from_tensor():
        optimizer.param_groups[index][option_key] = dtype(option_tensor.numpy()[0])

    return _from_tensor


# Traceback (TypeError)
Traceback (most recent call last):
File "train.py", line 641, in <module>
train_images(hps)
File "train.py", line 444, in train_images
train_step(batch, batch_idx, epoch, hps, model, opt, train_logger)
File "train.py", line 457, in train_step
opt.step()
File "/opt/conda/lib/python3.6/site-packages/horovod/torch/__init__.py", line 97, in step
return super(self.__class__, self).step(closure)
File "/opt/conda/lib/python3.6/site-packages/torch/optim/adamax.py", line 75, in step
exp_avg.mul_(beta1).add_(1 - beta1, grad)
TypeError: mul_() received an invalid combination of arguments - got (numpy.float32), but expected one of:
* (Tensor other)
didn't match because some of the arguments have invalid types: (numpy.float32)
* (float other)
didn't match because some of the arguments have invalid types: (numpy.float32)

# Fixed code
def _create_option_callback(index, option_key, option_tensor, dtypes):
    def _from_tensor():
        optimizer.param_groups[index][option_key] = _recursive_cast(
            option_tensor.numpy()[0], dtypes
        )

    return _from_tensor
# Buggy code
def _from_tensor():
    optimizer.param_groups[index][option_key] = dtype(option_tensor.numpy()[0])


# Traceback (TypeError)
Traceback (most recent call last):
File "train.py", line 641, in <module>
train_images(hps)
File "train.py", line 444, in train_images
train_step(batch, batch_idx, epoch, hps, model, opt, train_logger)
File "train.py", line 457, in train_step
opt.step()
File "/opt/conda/lib/python3.6/site-packages/horovod/torch/__init__.py", line 97, in step
return super(self.__class__, self).step(closure)
File "/opt/conda/lib/python3.6/site-packages/torch/optim/adamax.py", line 75, in step
exp_avg.mul_(beta1).add_(1 - beta1, grad)
TypeError: mul_() received an invalid combination of arguments - got (numpy.float32), but expected one of:
* (Tensor other)
didn't match because some of the arguments have invalid types: (numpy.float32)
* (float other)
didn't match because some of the arguments have invalid types: (numpy.float32)

# Fixed code
def _from_tensor():
    optimizer.param_groups[index][option_key] = _recursive_cast(
        option_tensor.numpy()[0], dtypes
    )
# Buggy code
def start(self, workers=1, max_queue_size=10):
    """Start the handler's workers.

    # Arguments
        workers: number of worker threads
        max_queue_size: queue size
            (when full, workers could block on `put()`)
    """
    if self.use_multiprocessing:
        self.executor_fn = lambda: multiprocessing.Pool(workers)
    else:
        self.executor_fn = lambda: ThreadPool(workers)
    self.workers = workers
    self.queue = queue.Queue(max_queue_size)
    self.stop_signal = threading.Event()
    self.run_thread = threading.Thread(target=self._run)
    self.run_thread.daemon = True
    self.run_thread.start()


# Traceback (KeyError)
Traceback (most recent call last):
File "C:\Users\elcombato\AppData\Local\Continuum\Anaconda3\envs\ml\lib\multiprocessing\pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "C:\Users\elcombato\AppData\Local\Continuum\Anaconda3\envs\ml\lib\site-packages\keras\utils\data_utils.py", line 392, in get_index
return _SHARED_SEQUENCES[uid][i]
KeyError: 0

# Fixed code
def start(self, workers=1, max_queue_size=10):
    """Start the handler's workers.

    # Arguments
        workers: number of worker threads
        max_queue_size: queue size
            (when full, workers could block on `put()`)
    """
    if self.use_multiprocessing:
        self.executor_fn = lambda seqs: multiprocessing.Pool(
            workers, initializer=init_pool, initargs=(seqs,)
        )
    else:
        # We do not need the init since it's threads.
        self.executor_fn = lambda _: ThreadPool(workers)
    self.workers = workers
    self.queue = queue.Queue(max_queue_size)
    self.stop_signal = threading.Event()
    self.run_thread = threading.Thread(target=self._run)
    self.run_thread.daemon = True
    self.run_thread.start()
# Buggy code
def _run(self):
    """Submits request to the executor and queue the `Future` objects."""
    sequence = list(range(len(self.sequence)))
    self._send_sequence()  # Share the initial sequence
    while True:
        if self.shuffle:
            random.shuffle(sequence)

        with closing(self.executor_fn()) as executor:
            for i in sequence:
                if self.stop_signal.is_set():
                    return
                self.queue.put(
                    executor.apply_async(get_index, (self.uid, i)), block=True
                )

            # Done with the current epoch, waiting for the final batches
            self._wait_queue()

            if self.stop_signal.is_set():
                # We're done
                return

        # Call the internal on epoch end.
        self.sequence.on_epoch_end()
        self._send_sequence()  # Update the pool


# Traceback (KeyError)
Traceback (most recent call last):
File "C:\Users\elcombato\AppData\Local\Continuum\Anaconda3\envs\ml\lib\multiprocessing\pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "C:\Users\elcombato\AppData\Local\Continuum\Anaconda3\envs\ml\lib\site-packages\keras\utils\data_utils.py", line 392, in get_index
return _SHARED_SEQUENCES[uid][i]
KeyError: 0

# Fixed code
def _run(self):
    """Submits request to the executor and queue the `Future` objects."""
    sequence = list(range(len(self.sequence)))
    self._send_sequence()  # Share the initial sequence
    while True:
        if self.shuffle:
            random.shuffle(sequence)

        with closing(self.executor_fn(_SHARED_SEQUENCES)) as executor:
            for i in sequence:
                if self.stop_signal.is_set():
                    return
                self.queue.put(
                    executor.apply_async(get_index, (self.uid, i)), block=True
                )

            # Done with the current epoch, waiting for the final batches
            self._wait_queue()

            if self.stop_signal.is_set():
                # We're done
                return

        # Call the internal on epoch end.
        self.sequence.on_epoch_end()
        self._send_sequence()  # Update the pool
# Buggy code
def close(self, timeout=no_default):
    """Close this client

    Clients will also close automatically when your Python session ends

    If you started a client without arguments like ``Client()`` then this
    will also close the local cluster that was started at the same time.

    See Also
    --------
    Client.restart
    """
    if timeout == no_default:
        timeout = self._timeout * 2
    # XXX handling of self.status here is not thread-safe
    if self.status == "closed":
        return
    self.status = "closing"

    if self.asynchronous:
        future = self._close()
        if timeout:
            future = gen.with_timeout(timedelta(seconds=timeout), future)
        return future

    if self._start_arg is None:
        with ignoring(AttributeError):
            self.cluster.close()

    sync(self.loop, self._close, fast=True)

    assert self.status == "closed"

    if self._should_close_loop and not shutting_down():
        self._loop_runner.stop()

    with ignoring(AttributeError):
        dask.config.set(scheduler=self._previous_scheduler)
    with ignoring(AttributeError):
        dask.config.set(shuffle=self._previous_shuffle)
    if self.get == dask.config.get("get", None):
        del dask.config.config["get"]


# Traceback (NotImplementedError)
$ python tmp/dask/shuffle_none.py
before client shuffle: MISSING
before client scheduler: MISSING
inside client shuffle: tasks
inside client scheduler: dask.distributed
after client shuffle: None
after client scheduler: None
Traceback (most recent call last):
...
NotImplementedError: Unknown shuffle method None

# Fixed code
def close(self, timeout=no_default):
    """Close this client

    Clients will also close automatically when your Python session ends

    If you started a client without arguments like ``Client()`` then this
    will also close the local cluster that was started at the same time.

    See Also
    --------
    Client.restart
    """
    if timeout == no_default:
        timeout = self._timeout * 2
    # XXX handling of self.status here is not thread-safe
    if self.status == "closed":
        return
    self.status = "closing"

    if self.asynchronous:
        future = self._close()
        if timeout:
            future = gen.with_timeout(timedelta(seconds=timeout), future)
        return future

    if self._start_arg is None:
        with ignoring(AttributeError):
            self.cluster.close()

    sync(self.loop, self._close, fast=True)

    assert self.status == "closed"

    if self._should_close_loop and not shutting_down():
        self._loop_runner.stop()
# Buggy code
def symlink(
    self,
    src,  # type: str
    dst,  # type: str
    label=None,  # type: Optional[str]
):
    # type: (...) -> None
    dst = self._normalize(dst)
    self._tag(dst, label)
    self._ensure_parent(dst)
    abs_src = src
    abs_dst = os.path.join(self.chroot, dst)
    os.symlink(abs_src, abs_dst)


# Traceback (FileNotFoundError)
$ mkdir src/
$ echo 'print("Hello World!")' > src/main.py
$ python -m pex -D src -otest.pex -e main
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/jsirois/dev/pantsbuild/jsirois-pex/pex/__main__.py", line 8, in <module>
__name__ == "__main__" and pex.main()
File "/home/jsirois/dev/pantsbuild/jsirois-pex/pex/bin/pex.py", line 1070, in main
pex_builder.freeze(bytecode_compile=options.compile)
File "/home/jsirois/dev/pantsbuild/jsirois-pex/pex/pex_builder.py", line 578, in freeze
self._prepare_code()
File "/home/jsirois/dev/pantsbuild/jsirois-pex/pex/pex_builder.py", line 506, in _prepare_code
self._pex_info.code_hash = CacheHelper.pex_code_hash(self._chroot.path())
File "/home/jsirois/dev/pantsbuild/jsirois-pex/pex/util.py", line 154, in pex_code_hash
return cls._compute_hash(names, stream_factory)
File "/home/jsirois/dev/pantsbuild/jsirois-pex/pex/util.py", line 131, in _compute_hash
with contextlib.closing(stream_factory(name)) as fp:
File "/home/jsirois/dev/pantsbuild/jsirois-pex/pex/util.py", line 152, in stream_factory
return open(os.path.join(d, name), "rb")  # noqa: T802
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpcb782oi_/main.py'

# Fixed code
def symlink(
    self,
    src,  # type: str
    dst,  # type: str
    label=None,  # type: Optional[str]
):
    # type: (...) -> None
    dst = self._normalize(dst)
    self._tag(dst, label)
    self._ensure_parent(dst)
    abs_src = os.path.abspath(src)
    abs_dst = os.path.join(self.chroot, dst)
    os.symlink(abs_src, abs_dst)
# Buggy code
def decode(cls, encoded):
    TRACER.log("creating PythonIdentity from encoded: %s" % encoded, V=9)
    values = json.loads(encoded)
    if len(values) != 7:
        raise cls.InvalidError("Invalid interpreter identity: %s" % encoded)

    supported_tags = values.pop("supported_tags")

    def iter_tags():
        for interpreter, abi, platform in supported_tags:
            yield tags.Tag(interpreter=interpreter, abi=abi, platform=platform)

    return cls(supported_tags=iter_tags(), **values)


# Traceback (ModuleNotFoundError)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-kh23prp9/setup.py", line 59, in <module>
'Programming Language :: Python :: 3.8',
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/__init__.py", line 169, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/wheel/wheel/bdist_wheel.py", line 228, in run
self.run_command('install')
File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/command/install.py", line 65, in run
return orig.install.run(self)
File "/usr/lib/python3.7/distutils/command/install.py", line 601, in run
self.run_command(cmd_name)
File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/command/install_scripts.py", line 22, in run
import setuptools.command.easy_install as ei  # vendor:skip
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/command/easy_install.py", line 69, in <module>
from setuptools.sandbox import run_setup  # vendor:skip
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/sandbox.py", line 24, in <module>
import pkg_resources.py31compat  # vendor:skip
ModuleNotFoundError: No module named 'pkg_resources.py31compat'
----------------------------------------
ERROR: Failed building wheel for boto3

# Fixed code
def decode(cls, encoded):
    TRACER.log("creating PythonIdentity from encoded: %s" % encoded, V=9)
    values = json.loads(encoded)
    if len(values) != 9:
        raise cls.InvalidError("Invalid interpreter identity: %s" % encoded)

    supported_tags = values.pop("supported_tags")

    def iter_tags():
        for interpreter, abi, platform in supported_tags:
            yield tags.Tag(interpreter=interpreter, abi=abi, platform=platform)

    return cls(supported_tags=iter_tags(), **values)
# Buggy code
def encode(self):
    values = dict(
        binary=self._binary,
        python_tag=self._python_tag,
        abi_tag=self._abi_tag,
        platform_tag=self._platform_tag,
        version=self._version,
        supported_tags=[
            (tag.interpreter, tag.abi, tag.platform) for tag in self._supported_tags
        ],
        env_markers=self._env_markers,
    )
    return json.dumps(values, sort_keys=True)


# Traceback (ModuleNotFoundError)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-kh23prp9/setup.py", line 59, in <module>
'Programming Language :: Python :: 3.8',
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/__init__.py", line 169, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/wheel/wheel/bdist_wheel.py", line 228, in run
self.run_command('install')
File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/command/install.py", line 65, in run
return orig.install.run(self)
File "/usr/lib/python3.7/distutils/command/install.py", line 601, in run
self.run_command(cmd_name)
File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/command/install_scripts.py", line 22, in run
import setuptools.command.easy_install as ei  # vendor:skip
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/command/easy_install.py", line 69, in <module>
from setuptools.sandbox import run_setup  # vendor:skip
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/sandbox.py", line 24, in <module>
import pkg_resources.py31compat  # vendor:skip
ModuleNotFoundError: No module named 'pkg_resources.py31compat'
----------------------------------------
ERROR: Failed building wheel for boto3

# Fixed code
def encode(self):
    values = dict(
        binary=self._binary,
        prefix=self._prefix,
        base_prefix=self._base_prefix,
        python_tag=self._python_tag,
        abi_tag=self._abi_tag,
        platform_tag=self._platform_tag,
        version=self._version,
        supported_tags=[
            (tag.interpreter, tag.abi, tag.platform) for tag in self._supported_tags
        ],
        env_markers=self._env_markers,
    )
    return json.dumps(values, sort_keys=True)
# Buggy code
def binary(self):
    return self._binary


# Traceback (ModuleNotFoundError)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-kh23prp9/setup.py", line 59, in <module>
'Programming Language :: Python :: 3.8',
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/__init__.py", line 169, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.7/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/wheel/wheel/bdist_wheel.py", line 228, in run
self.run_command('install')
File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/command/install.py", line 65, in run
return orig.install.run(self)
File "/usr/lib/python3.7/distutils/command/install.py", line 601, in run
self.run_command(cmd_name)
File "/usr/lib/python3.7/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.7/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/command/install_scripts.py", line 22, in run
import setuptools.command.easy_install as ei  # vendor:skip
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/command/easy_install.py", line 69, in <module>
from setuptools.sandbox import run_setup  # vendor:skip
File "/root/.pex/pip.pex/aef609891d42d65c887d1aeee58c46f6713a7e49/.deps/setuptools/setuptools/sandbox.py", line 24, in <module>
import pkg_resources.py31compat  # vendor:skip
ModuleNotFoundError: No module named 'pkg_resources.py31compat'
----------------------------------------
ERROR: Failed building wheel for boto3

# Fixed code
def binary(self):
    # type: () -> str
    return self._binary