gurudesh/pytracebugs huggingface dataset:
# Buggy code
def set_data_dir(proj_data_dir):
    """
    Set the data directory for PROJ to use.

    Parameters
    ----------
    proj_data_dir: str
        The path to rhe PROJ data directory.
    """
    global _USER_PROJ_DATA
    _USER_PROJ_DATA = proj_data_dir
    # reset search paths
    from pyproj._datadir import PYPROJ_CONTEXT

    PYPROJ_CONTEXT.set_search_paths()


# Traceback (pyproj.exceptions.DataDirError)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
...
File "/opt/conda/lib/python3.7/site-packages/geopandas/geodataframe.py", line 459, in to_crs
geom = df.geometry.to_crs(crs=crs, epsg=epsg)
File "/opt/conda/lib/python3.7/site-packages/geopandas/geoseries.py", line 304, in to_crs
proj_in = pyproj.Proj(self.crs, preserve_units=True)
File "/opt/conda/lib/python3.7/site-packages/pyproj/proj.py", line 147, in __init__
self.crs = CRS.from_user_input(projparams if projparams is not None else kwargs)
File "/opt/conda/lib/python3.7/site-packages/pyproj/crs.py", line 435, in from_user_input
return cls(value)
File "/opt/conda/lib/python3.7/site-packages/pyproj/crs.py", line 304, in __init__
super(CRS, self).__init__(projstring)
File "pyproj/_crs.pyx", line 1308, in pyproj._crs._CRS.__init__
File "pyproj/_datadir.pyx", line 18, in pyproj._datadir.get_pyproj_context
File "/opt/conda/lib/python3.7/site-packages/pyproj/datadir.py", line 99, in get_data_dir
"Valid PROJ data directory not found. "
pyproj.exceptions.DataDirError: Valid PROJ data directory not found. Either set the path using the environmental variable PROJ_LIB or with `pyproj.datadir.set_data_dir`.

# Fixed code
def set_data_dir(proj_data_dir):
    """
    Set the data directory for PROJ to use.

    Parameters
    ----------
    proj_data_dir: str
        The path to rhe PROJ data directory.
    """
    global _USER_PROJ_DATA
    _USER_PROJ_DATA = proj_data_dir
    # reset search paths
    from pyproj._datadir import PYPROJ_CONTEXT

    PYPROJ_CONTEXT.set_search_paths(reset=True)
# Buggy code
def set_data_dir(proj_data_dir):
    """
    Set the data directory for PROJ to use.

    Parameters
    ----------
    proj_data_dir: str
        The path to rhe PROJ data directory.
    """
    global _USER_PROJ_DATA
    global _VALIDATED_PROJ_DATA
    _USER_PROJ_DATA = proj_data_dir
    # set to none to re-validate
    _VALIDATED_PROJ_DATA = None


# Traceback (ProjError)
97%|█████████████████████████████████▊ | 88243/91210 [00:26<00:00, 6190.94it/s]
CRSs instantiated: 507
CRSs instantiated (cache hits included): 88603
Transformers instantiated: 502
Transformers instantiated (cache hits included): 88389
---------------------------------------------------------------------------
ProjError                                 Traceback (most recent call last)
... <snip> ...
~/.local/share/virtualenvs/bug-Ew6sNC7W/lib/python3.7/site-packages/pyproj/transformer.py in from_proj(proj_from, proj_to, skip_equivalent, always_xy)

pyproj/_transformer.pyx in pyproj._transformer._Transformer.from_crs()

ProjError: Error creating CRS to CRS.: (Internal Proj Error: proj_create: no dat
abase context specified)

In [2]:
Do you really want to exit ([y]/n)?

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/home/elias/.local/share/virtualenvs/bug-Ew6sNC7W/lib/python3.7/site-packages/IPython/core/history.py", line 578, in end_session
sqlite3.OperationalError: unable to open database file

# Fixed code
def set_data_dir(proj_data_dir):
    """
    Set the data directory for PROJ to use.

    Parameters
    ----------
    proj_data_dir: str
        The path to rhe PROJ data directory.
    """
    global _USER_PROJ_DATA
    _USER_PROJ_DATA = proj_data_dir
    # reset search paths
    from pyproj._datadir import PYPROJ_CONTEXT

    PYPROJ_CONTEXT.set_search_paths()
# Buggy code
def from_crs(crs_from, crs_to, skip_equivalent=False, always_xy=False):
    """Make a Transformer from a :obj:`~pyproj.crs.CRS` or input used to create one.

    Parameters
    ----------
    crs_from: ~pyproj.crs.CRS or input used to create one
        Projection of input data.
    crs_to: ~pyproj.crs.CRS or input used to create one
        Projection of output data.
    skip_equivalent: bool, optional
        If true, will skip the transformation operation if input and output
        projections are equivalent. Default is false.
    always_xy: bool, optional
        If true, the transform method will accept as input and return as output
        coordinates using the traditional GIS order, that is longitude, latitude
        for geographic CRS and easting, northing for most projected CRS.
        Default is false.

    Returns
    -------
    :obj:`~Transformer`

    """
    transformer = Transformer()
    transformer._transformer = _Transformer.from_crs(
        CRS.from_user_input(crs_from),
        CRS.from_user_input(crs_to),
        skip_equivalent=skip_equivalent,
        always_xy=always_xy,
    )
    return transformer


# Traceback (AttributeError)
In [4]: t = pyproj.Transformer()

In [5]: t
Out[5]: <pyproj.transformer.Transformer at 0x7fd75ff9b860>

In [6]: t.transform(0, 0)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-65405fa99360> in <module>
----> 1 t.transform(0, 0)

~/scipy/repos/pyproj/pyproj/transformer.py in transform(self, xx, yy, zz, tt, radians, errcheck, direction)
207             intime = None
208         # call pj_transform.  inx,iny,inz buffers modified in place.
--> 209         self._transformer._transform(
210             inx,
211             iny,

AttributeError: 'Transformer' object has no attribute '_transformer'

# Fixed code
def from_crs(crs_from, crs_to, skip_equivalent=False, always_xy=False):
    """Make a Transformer from a :obj:`~pyproj.crs.CRS` or input used to create one.

    Parameters
    ----------
    crs_from: ~pyproj.crs.CRS or input used to create one
        Projection of input data.
    crs_to: ~pyproj.crs.CRS or input used to create one
        Projection of output data.
    skip_equivalent: bool, optional
        If true, will skip the transformation operation if input and output
        projections are equivalent. Default is false.
    always_xy: bool, optional
        If true, the transform method will accept as input and return as output
        coordinates using the traditional GIS order, that is longitude, latitude
        for geographic CRS and easting, northing for most projected CRS.
        Default is false.

    Returns
    -------
    :obj:`~Transformer`

    """
    transformer = Transformer(
        _Transformer.from_crs(
            CRS.from_user_input(crs_from),
            CRS.from_user_input(crs_to),
            skip_equivalent=skip_equivalent,
            always_xy=always_xy,
        )
    )
    return transformer
# Buggy code
def from_pipeline(proj_pipeline):
    """Make a Transformer from a PROJ pipeline string.

    https://proj4.org/operations/pipeline.html

    Parameters
    ----------
    proj_pipeline: str
        Projection pipeline string.

    Returns
    -------
    ~Transformer

    """
    transformer = Transformer()
    transformer._transformer = _Transformer.from_pipeline(cstrencode(proj_pipeline))
    return transformer


# Traceback (AttributeError)
In [4]: t = pyproj.Transformer()

In [5]: t
Out[5]: <pyproj.transformer.Transformer at 0x7fd75ff9b860>

In [6]: t.transform(0, 0)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-65405fa99360> in <module>
----> 1 t.transform(0, 0)

~/scipy/repos/pyproj/pyproj/transformer.py in transform(self, xx, yy, zz, tt, radians, errcheck, direction)
207             intime = None
208         # call pj_transform.  inx,iny,inz buffers modified in place.
--> 209         self._transformer._transform(
210             inx,
211             iny,

AttributeError: 'Transformer' object has no attribute '_transformer'

# Fixed code
def from_pipeline(proj_pipeline):
    """Make a Transformer from a PROJ pipeline string.

    https://proj4.org/operations/pipeline.html

    Parameters
    ----------
    proj_pipeline: str
        Projection pipeline string.

    Returns
    -------
    ~Transformer

    """
    return Transformer(_Transformer.from_pipeline(cstrencode(proj_pipeline)))
# Buggy code
def _dict2string(projparams):
    # convert a dict to a proj4 string.
    pjargs = []
    for key, value in projparams.items():
        # the towgs84 as list
        if isinstance(value, (list, tuple)):
            value = ",".join([str(val) for val in value])
        # issue 183 (+ no_rot)
        if value is None or value is True:
            pjargs.append("+" + key + " ")
        elif value is False:
            pass
        else:
            pjargs.append("+" + key + "=" + str(value) + " ")
    return "".join(pjargs)


# Traceback (AttributeError)
from pyproj import Proj
Proj({'a': 6371229.0, 'b': 6371229.0, 'lon_0': -10.0, 'o_lat_p': 30.0, 'o_lon_p': 0.0, 'o_proj': 'longlat', 'proj'
: 'ob_tran'})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../lib/python3.7/site-packages/pyproj/proj.py", line 303, in __init__
cstrencode(self.crs.to_proj4().replace("+type=crs", "").strip())
AttributeError: 'NoneType' object has no attribute 'replace'

# Fixed code
def _dict2string(projparams):
    # convert a dict to a proj4 string.
    pjargs = []
    proj_inserted = False
    for key, value in projparams.items():
        # the towgs84 as list
        if isinstance(value, (list, tuple)):
            value = ",".join([str(val) for val in value])
        # issue 183 (+ no_rot)
        if value is None or value is True:
            pjargs.append("+{key}".format(key=key))
        elif value is False:
            pass
        # make sure string starts with proj or init
        elif not proj_inserted and key in ("init", "proj"):
            pjargs.insert(0, "+{key}={value}".format(key=key, value=value))
            proj_inserted = True
        else:
            pjargs.append("+{key}={value}".format(key=key, value=value))
    return " ".join(pjargs)
# Buggy code
def __call__(self, tf_method):
    @wraps(tf_method)
    def runnable(instance, *np_args):
        graph_name = "_" + tf_method.__name__ + "_graph"
        if not hasattr(instance, graph_name):
            instance._compile()
            self.tf_args = [tf.placeholder(*a) for a in self.tf_arg_tuples]
            with instance.tf_mode():
                graph = tf_method(instance, *self.tf_args)
            setattr(instance, graph_name, graph)
        feed_dict = dict(zip(self.tf_args, np_args))
        feed_dict[instance._free_vars] = instance.get_free_state()
        graph = getattr(instance, graph_name)
        return instance._session.run(graph, feed_dict=feed_dict)

    return runnable


# Traceback (ValueError)
Traceback (most recent call last):
File "/Users/mqbssaby/PrivateProjects/BranchedGP/runfile.py", line 29, in <module>
[mu,var] = m.predict_f(X)
File "/Users/mqbssaby/pythonlibs/GPflow/GPflow/model.py", line 82, in runnable
return instance._session.run(graph, feed_dict=feed_dict)
File "/Users/mqbssaby/anaconda/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 340, in run
run_metadata_ptr)
File "/Users/mqbssaby/anaconda/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 553, in _run
% (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (4,) for Tensor u'Variable:0', which has shape '(5,)'

# Fixed code
def __call__(self, tf_method):
    @wraps(tf_method)
    def runnable(instance, *np_args):
        graph_name = "_" + tf_method.__name__ + "_graph"
        if not hasattr(instance, graph_name):
            if instance._needs_recompile:
                instance._compile()  # ensures free_vars is up-to-date.
            self.tf_args = [tf.placeholder(*a) for a in self.tf_arg_tuples]
            with instance.tf_mode():
                graph = tf_method(instance, *self.tf_args)
            setattr(instance, graph_name, graph)
        feed_dict = dict(zip(self.tf_args, np_args))
        feed_dict[instance._free_vars] = instance.get_free_state()
        graph = getattr(instance, graph_name)
        return instance._session.run(graph, feed_dict=feed_dict)

    return runnable
# Buggy code
def runnable(instance, *np_args):
    graph_name = "_" + tf_method.__name__ + "_graph"
    if not hasattr(instance, graph_name):
        instance._compile()
        self.tf_args = [tf.placeholder(*a) for a in self.tf_arg_tuples]
        with instance.tf_mode():
            graph = tf_method(instance, *self.tf_args)
        setattr(instance, graph_name, graph)
    feed_dict = dict(zip(self.tf_args, np_args))
    feed_dict[instance._free_vars] = instance.get_free_state()
    graph = getattr(instance, graph_name)
    return instance._session.run(graph, feed_dict=feed_dict)


# Traceback (ValueError)
Traceback (most recent call last):
File "/Users/mqbssaby/PrivateProjects/BranchedGP/runfile.py", line 29, in <module>
[mu,var] = m.predict_f(X)
File "/Users/mqbssaby/pythonlibs/GPflow/GPflow/model.py", line 82, in runnable
return instance._session.run(graph, feed_dict=feed_dict)
File "/Users/mqbssaby/anaconda/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 340, in run
run_metadata_ptr)
File "/Users/mqbssaby/anaconda/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 553, in _run
% (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (4,) for Tensor u'Variable:0', which has shape '(5,)'

# Fixed code
def runnable(instance, *np_args):
    graph_name = "_" + tf_method.__name__ + "_graph"
    if not hasattr(instance, graph_name):
        if instance._needs_recompile:
            instance._compile()  # ensures free_vars is up-to-date.
        self.tf_args = [tf.placeholder(*a) for a in self.tf_arg_tuples]
        with instance.tf_mode():
            graph = tf_method(instance, *self.tf_args)
        setattr(instance, graph_name, graph)
    feed_dict = dict(zip(self.tf_args, np_args))
    feed_dict[instance._free_vars] = instance.get_free_state()
    graph = getattr(instance, graph_name)
    return instance._session.run(graph, feed_dict=feed_dict)
# Buggy code
def on_error(self, error, debug):
    error_msg = str(error).decode()
    debug_msg = debug.decode()
    gst_logger.debug("Got ERROR bus message: error=%r debug=%r", error_msg, debug_msg)
    gst_logger.error("GStreamer error: %s", error_msg)
    # TODO: is this needed?
    self._audio.stop_playback()


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/jodal/mopidy-dev/mopidy/mopidy/audio/actor.py", line 219, in on_message
self.on_error(error, debug)
File "/home/jodal/mopidy-dev/mopidy/mopidy/audio/actor.py", line 328, in on_error
error_msg = str(error).decode()
AttributeError: 'str' object has no attribute 'decode'

# Fixed code
def on_error(self, error, debug):
    gst_logger.error(f"GStreamer error: {error.message}")
    gst_logger.debug(f"Got ERROR bus message: error={error!r} debug={debug!r}")

    # TODO: is this needed?
    self._audio.stop_playback()
# Buggy code
def on_warning(self, error, debug):
    error_msg = str(error).decode()
    debug_msg = debug.decode()
    gst_logger.warning("GStreamer warning: %s", error_msg)
    gst_logger.debug("Got WARNING bus message: error=%r debug=%r", error_msg, debug_msg)


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/jodal/mopidy-dev/mopidy/mopidy/audio/actor.py", line 219, in on_message
self.on_error(error, debug)
File "/home/jodal/mopidy-dev/mopidy/mopidy/audio/actor.py", line 328, in on_error
error_msg = str(error).decode()
AttributeError: 'str' object has no attribute 'decode'

# Fixed code
def on_warning(self, error, debug):
    gst_logger.warning(f"GStreamer warning: {error.message}")
    gst_logger.debug(f"Got WARNING bus message: error={error!r} debug={debug!r}")
# Buggy code
def on_stream_start(self):
    gst_logger.debug("Got STREAM_START bus message")
    uri = self._audio._pending_uri
    logger.debug("Audio event: stream_changed(uri=%r)", uri)
    AudioListener.send("stream_changed", uri=uri)

    # Emit any postponed tags that we got after about-to-finish.
    tags, self._audio._pending_tags = self._audio._pending_tags, None
    self._audio._tags = tags

    if tags:
        logger.debug("Audio event: tags_changed(tags=%r)", tags.keys())
        AudioListener.send("tags_changed", tags=tags.keys())


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/jodal/mopidy-dev/mopidy/mopidy/audio/actor.py", line 225, in on_message
self.on_tag(taglist)
File "/home/jodal/mopidy-dev/mopidy/mopidy/audio/actor.py", line 340, in on_tag
if self._audio._tags.get(key, unique) != value:
AttributeError: 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
File "/home/jodal/mopidy-dev/mopidy/mopidy/audio/actor.py", line 225, in on_message
self.on_tag(taglist)
File "/home/jodal/mopidy-dev/mopidy/mopidy/audio/actor.py", line 340, in on_tag
if self._audio._tags.get(key, unique) != value:
AttributeError: 'NoneType' object has no attribute 'get'

# Fixed code
def on_stream_start(self):
    gst_logger.debug("Got STREAM_START bus message")
    uri = self._audio._pending_uri
    logger.debug("Audio event: stream_changed(uri=%r)", uri)
    AudioListener.send("stream_changed", uri=uri)

    # Emit any postponed tags that we got after about-to-finish.
    tags, self._audio._pending_tags = self._audio._pending_tags, None
    self._audio._tags = tags or {}

    if tags:
        logger.debug("Audio event: tags_changed(tags=%r)", tags.keys())
        AudioListener.send("tags_changed", tags=tags.keys())
# Buggy code
def _get_library(args, config):
    libraries = dict((l.name, l) for l in args.registry["local:library"])
    library_name = config["local"]["library"]

    if library_name not in libraries:
        logger.warning("Local library %s not found", library_name)
        return 1

    logger.debug("Using %s as the local library", library_name)
    return libraries[library_name](config)


# Traceback (AttributeError)
INFO     Starting Mopidy 1.1.1
INFO     Loading config from builtin defaults
INFO     Loading config from /etc/mopidy/mopidy.conf
INFO     Loading config from command line options
INFO     Enabled extensions: mpd, http, stream, podcast-gpodder, m3u, podcast-itunes, softwaremixer, file, musicbox_webclient, podcast, local, tunein, soundcloud
INFO     Disabled extensions: none
WARNING  Local library images not found
INFO     Found 8597 files in media_dir.
ERROR    'int' object has no attribute 'load'
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mopidy/__main__.py", line 158, in main
return args.command.run(args, proxied_config)
File "/usr/lib/python2.7/dist-packages/mopidy/local/commands.py", line 91, in run
num_tracks = library.load()
AttributeError: 'int' object has no attribute 'load'
Traceback (most recent call last):
File "/usr/bin/mopidy", line 9, in <module>
load_entry_point('Mopidy==1.1.1', 'console_scripts', 'mopidy')()
File "/usr/lib/python2.7/dist-packages/mopidy/__main__.py", line 158, in main
return args.command.run(args, proxied_config)
File "/usr/lib/python2.7/dist-packages/mopidy/local/commands.py", line 91, in run
num_tracks = library.load()
AttributeError: 'int' object has no attribute 'load'

# Fixed code
def _get_library(args, config):
    libraries = dict((l.name, l) for l in args.registry["local:library"])
    library_name = config["local"]["library"]

    if library_name not in libraries:
        logger.error("Local library %s not found", library_name)
        return None

    logger.debug("Using %s as the local library", library_name)
    return libraries[library_name](config)
# Buggy code
def run(self, args, config):
    library = _get_library(args, config)
    prompt = "\nAre you sure you want to clear the library? [y/N] "

    if compat.input(prompt).lower() != "y":
        print("Clearing library aborted.")
        return 0

    if library.clear():
        print("Library successfully cleared.")
        return 0

    print("Unable to clear library.")
    return 1


# Traceback (AttributeError)
INFO     Starting Mopidy 1.1.1
INFO     Loading config from builtin defaults
INFO     Loading config from /etc/mopidy/mopidy.conf
INFO     Loading config from command line options
INFO     Enabled extensions: mpd, http, stream, podcast-gpodder, m3u, podcast-itunes, softwaremixer, file, musicbox_webclient, podcast, local, tunein, soundcloud
INFO     Disabled extensions: none
WARNING  Local library images not found
INFO     Found 8597 files in media_dir.
ERROR    'int' object has no attribute 'load'
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mopidy/__main__.py", line 158, in main
return args.command.run(args, proxied_config)
File "/usr/lib/python2.7/dist-packages/mopidy/local/commands.py", line 91, in run
num_tracks = library.load()
AttributeError: 'int' object has no attribute 'load'
Traceback (most recent call last):
File "/usr/bin/mopidy", line 9, in <module>
load_entry_point('Mopidy==1.1.1', 'console_scripts', 'mopidy')()
File "/usr/lib/python2.7/dist-packages/mopidy/__main__.py", line 158, in main
return args.command.run(args, proxied_config)
File "/usr/lib/python2.7/dist-packages/mopidy/local/commands.py", line 91, in run
num_tracks = library.load()
AttributeError: 'int' object has no attribute 'load'

# Fixed code
def run(self, args, config):
    library = _get_library(args, config)
    if library is None:
        return 1

    prompt = "\nAre you sure you want to clear the library? [y/N] "

    if compat.input(prompt).lower() != "y":
        print("Clearing library aborted.")
        return 0

    if library.clear():
        print("Library successfully cleared.")
        return 0

    print("Unable to clear library.")
    return 1
# Buggy code
def send(self, data):
    """Send data to client, return any unsent data."""
    try:
        sent = self.sock.send(data)
        return data[sent:]
    except socket.error as e:
        if e.errno in (errno.EWOULDBLOCK, errno.EINTR):
            return data
        self.stop("Unexpected client error: %s" % e)
        return b""


# Traceback (UnicodeDecodeError)
2015-02-04 06:30:11,901 ERROR [3714:MpdSession-27] pykka: Unhandled exception in MpdSession (urn:uuid:9595028c-486c-4c89-813a-785c3cafc057):
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 200, in _actor_loop
response = self._handle_receive(message)
File "/usr/lib/python2.7/dist-packages/pykka/actor.py", line 303, in _handle_receive
return self.on_receive(message)
File "/usr/lib/python2.7/dist-packages/mopidy/utils/network.py", line 366, in on_receive
self.on_line_received(line)
File "/usr/lib/python2.7/dist-packages/mopidy/mpd/session.py", line 41, in on_line_received
self.send_lines(response)
File "/usr/lib/python2.7/dist-packages/mopidy/utils/network.py", line 428, in send_lines
self.connection.queue_send(self.encode(data))
File "/usr/lib/python2.7/dist-packages/mopidy/utils/network.py", line 189, in queue_send
self.send_buffer = self.send(self.send_buffer + data)
File "/usr/lib/python2.7/dist-packages/mopidy/utils/network.py", line 202, in send
self.stop('Unexpected client error: %s' % e)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 16: ordinal not in range(128)

# Fixed code
def send(self, data):
    """Send data to client, return any unsent data."""
    try:
        sent = self.sock.send(data)
        return data[sent:]
    except socket.error as e:
        if e.errno in (errno.EWOULDBLOCK, errno.EINTR):
            return data
        self.stop("Unexpected client error: %s" % encoding.locale_decode(e))
        return b""
# Buggy code
def push(self, buffer_):
    if buffer_ is None:
        gst_logger.debug("Sending appsrc end-of-stream event.")
        return self._source.emit("end-of-stream") == gst.FLOW_OK
    else:
        return self._source.emit("push-buffer", buffer_) == gst.FLOW_OK


# Traceback (AttributeError)
^CINFO     Interrupted. Exiting...
INFO     Stopping Mopidy frontends
INFO     Stopping Mopidy core
INFO     Stopping Mopidy backends
From callback <function music_delivery at 0x7fa14c3c8938>:
Traceback (most recent call last):
File "/home/jodal/dev/pyspotify2/spotify/session.py", line 989, in music_delivery
spotify._session_instance, audio_format, frames_bytes, num_frames)
File "/home/jodal/dev/pyspotify2/spotify/utils.py", line 108, in call
return listener.callback(*args)
File "/home/jodal/dev/mopidy-spotify/mopidy_spotify/playback.py", line 159, in music_delivery_callback
if audio_actor.emit_data(buffer_).get():
File "build/bdist.linux-x86_64/egg/pykka/future.py", line 299, in get
File "build/bdist.linux-x86_64/egg/pykka/actor.py", line 200, in _actor_loop
File "build/bdist.linux-x86_64/egg/pykka/actor.py", line 294, in _handle_receive
File "/home/jodal/dev/mopidy/mopidy/audio/actor.py", line 587, in emit_data
return self._appsrc.push(buffer_)
File "/home/jodal/dev/mopidy/mopidy/audio/actor.py", line 135, in push
return self._source.emit('push-buffer', buffer_) == gst.FLOW_OK
AttributeError: 'NoneType' object has no attribute 'emit'
INFO     Stopping Mopidy audio
INFO     Stopping Mopidy mixer

# Fixed code
def push(self, buffer_):
    if self._source is None:
        return False

    if buffer_ is None:
        gst_logger.debug("Sending appsrc end-of-stream event.")
        return self._source.emit("end-of-stream") == gst.FLOW_OK
    else:
        return self._source.emit("push-buffer", buffer_) == gst.FLOW_OK
# Buggy code
def recv_callback(self, fd, flags):
    if flags & (gobject.IO_ERR | gobject.IO_HUP):
        self.stop("Bad client flags: %s" % flags)
        return True

    try:
        data = self.sock.recv(4096)
    except socket.error as e:
        if e.errno not in (errno.EWOULDBLOCK, errno.EINTR):
            self.stop("Unexpected client error: %s" % e)
        return True

    if not data:
        self.actor_ref.tell({"close": True})
        self.disable_recv()
        return True

    try:
        self.actor_ref.tell({"received": data})
    except pykka.ActorDeadError:
        self.stop("Actor is dead.")

    return True


# Traceback (TypeError)
Traceback (most recent call last):
File "/home/adamcik/dev/mopidy/mopidy/utils/network.py", line 272, in recv_callback
self.disable_recv()
File "/home/adamcik/dev/mopidy/mopidy/utils/network.py", line 236, in disable_recv
gobject.source_remove(self.recv_id)
TypeError: an integer is required

# Fixed code
def recv_callback(self, fd, flags):
    if flags & (gobject.IO_ERR | gobject.IO_HUP):
        self.stop("Bad client flags: %s" % flags)
        return True

    try:
        data = self.sock.recv(4096)
    except socket.error as e:
        if e.errno not in (errno.EWOULDBLOCK, errno.EINTR):
            self.stop("Unexpected client error: %s" % e)
        return True

    if not data:
        self.disable_recv()
        self.actor_ref.tell({"close": True})
        return True

    try:
        self.actor_ref.tell({"received": data})
    except pykka.ActorDeadError:
        self.stop("Actor is dead.")

    return True
# Buggy code
def _retrieve(source_key, target_key, target):
    if source_key in data:
        target[target_key] = data[source_key]


# Traceback (TypeError)
erik@faust:~$  mopidy
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 5, in <module>
main()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 48, in main
options = parse_options()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 85, in parse_options
help='show GStreamer help options')
File "/usr/lib64/python2.6/optparse.py", line 1012, in add_option
raise TypeError, "invalid arguments"
TypeError: invalid arguments
erik@faust:~$  python --version
Python 2.6
erik@faust:~$  uname -a
Linux faust 3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
erik@faust:~$  cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
erik@faust:~$

# Fixed code
def _retrieve(source_key, target_key, target):
    if source_key in data:
        target[str(target_key)] = data[source_key]
# Buggy code
def parse_options():
    parser = optparse.OptionParser(version="Mopidy %s" % versioning.get_version())
    parser.add_option(
        "-q",
        "--quiet",
        action="store_const",
        const=0,
        dest="verbosity_level",
        help="less output (warning level)",
    )
    parser.add_option(
        "-v",
        "--verbose",
        action="count",
        default=1,
        dest="verbosity_level",
        help="more output (debug level)",
    )
    return parser.parse_args(args=mopidy_args)[0]


# Traceback (TypeError)
erik@faust:~$  mopidy
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 5, in <module>
main()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 48, in main
options = parse_options()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 85, in parse_options
help='show GStreamer help options')
File "/usr/lib64/python2.6/optparse.py", line 1012, in add_option
raise TypeError, "invalid arguments"
TypeError: invalid arguments
erik@faust:~$  python --version
Python 2.6
erik@faust:~$  uname -a
Linux faust 3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
erik@faust:~$  cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
erik@faust:~$

# Fixed code
def parse_options():
    parser = optparse.OptionParser(version="Mopidy %s" % versioning.get_version())
    # NOTE Python 2.6: To support Python versions < 2.6.2rc1 we must use
    # bytestrings for the first argument to ``add_option``
    # See https://github.com/mopidy/mopidy/issues/302 for details
    parser.add_option(
        b"-q",
        "--quiet",
        action="store_const",
        const=0,
        dest="verbosity_level",
        help="less output (warning level)",
    )
    parser.add_option(
        b"-v",
        "--verbose",
        action="count",
        default=1,
        dest="verbosity_level",
        help="more output (debug level)",
    )
    return parser.parse_args(args=mopidy_args)[0]
# Buggy code
def __init__(self, core):
    super(MpdFrontend, self).__init__()
    hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
    port = settings.MPD_SERVER_PORT

    try:
        network.Server(
            hostname,
            port,
            protocol=session.MpdSession,
            protocol_kwargs={"core": core},
            max_connections=settings.MPD_SERVER_MAX_CONNECTIONS,
            timeout=settings.MPD_SERVER_CONNECTION_TIMEOUT,
        )
    except IOError as error:
        logger.error("MPD server startup failed: %s", encoding.locale_decode(error))
        sys.exit(1)

    logger.info("MPD server running at [%s]:%s", hostname, port)


# Traceback (TypeError)
erik@faust:~$  mopidy
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 5, in <module>
main()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 48, in main
options = parse_options()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 85, in parse_options
help='show GStreamer help options')
File "/usr/lib64/python2.6/optparse.py", line 1012, in add_option
raise TypeError, "invalid arguments"
TypeError: invalid arguments
erik@faust:~$  python --version
Python 2.6
erik@faust:~$  uname -a
Linux faust 3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
erik@faust:~$  cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
erik@faust:~$

# Fixed code
def __init__(self, core):
    super(MpdFrontend, self).__init__()
    hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
    port = settings.MPD_SERVER_PORT

    # NOTE: dict key must be bytestring to work on Python < 2.6.5
    # See https://github.com/mopidy/mopidy/issues/302 for details
    try:
        network.Server(
            hostname,
            port,
            protocol=session.MpdSession,
            protocol_kwargs={b"core": core},
            max_connections=settings.MPD_SERVER_MAX_CONNECTIONS,
            timeout=settings.MPD_SERVER_CONNECTION_TIMEOUT,
        )
    except IOError as error:
        logger.error("MPD server startup failed: %s", encoding.locale_decode(error))
        sys.exit(1)

    logger.info("MPD server running at [%s]:%s", hostname, port)
# Buggy code
def decorator(func):
    match = re.search("([a-z_]+)", pattern)
    if match is not None:
        mpd_commands.add(MpdCommand(name=match.group(), auth_required=auth_required))
    compiled_pattern = re.compile(pattern, flags=re.UNICODE)
    if compiled_pattern in request_handlers:
        raise ValueError("Tried to redefine handler for %s with %s" % (pattern, func))
    request_handlers[compiled_pattern] = func
    func.__doc__ = "    - *Pattern:* ``%s``\n\n%s" % (pattern, func.__doc__ or "")
    return func


# Traceback (TypeError)
erik@faust:~$  mopidy
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 5, in <module>
main()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 48, in main
options = parse_options()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 85, in parse_options
help='show GStreamer help options')
File "/usr/lib64/python2.6/optparse.py", line 1012, in add_option
raise TypeError, "invalid arguments"
TypeError: invalid arguments
erik@faust:~$  python --version
Python 2.6
erik@faust:~$  uname -a
Linux faust 3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
erik@faust:~$  cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
erik@faust:~$

# Fixed code
def decorator(func):
    match = re.search("([a-z_]+)", pattern)
    if match is not None:
        mpd_commands.add(MpdCommand(name=match.group(), auth_required=auth_required))
    # NOTE: Make pattern a bytestring to get bytestring keys in the dict
    # returned from matches.groupdict(), which is again used as a **kwargs
    # dict. This is needed to work on Python < 2.6.5. See
    # https://github.com/mopidy/mopidy/issues/302 for details.
    bytestring_pattern = pattern.encode("utf-8")
    compiled_pattern = re.compile(bytestring_pattern, flags=re.UNICODE)
    if compiled_pattern in request_handlers:
        raise ValueError("Tried to redefine handler for %s with %s" % (pattern, func))
    request_handlers[compiled_pattern] = func
    func.__doc__ = "    - *Pattern:* ``%s``\n\n%s" % (pattern, func.__doc__ or "")
    return func
# Buggy code
def __init__(self, core):
    super(MpdFrontend, self).__init__()
    hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
    port = settings.MPD_SERVER_PORT

    # NOTE: dict key must be bytestring to work on Python < 2.6.5
    # See https://github.com/mopidy/mopidy/issues/302 for details
    try:
        network.Server(
            hostname,
            port,
            protocol=session.MpdSession,
            protocol_kwargs={b"core": core},
            max_connections=settings.MPD_SERVER_MAX_CONNECTIONS,
            timeout=settings.MPD_SERVER_CONNECTION_TIMEOUT,
        )
    except IOError as error:
        logger.error("MPD server startup failed: %s", encoding.locale_decode(error))
        sys.exit(1)

    logger.info("MPD server running at [%s]:%s", hostname, port)


# Traceback (TypeError)
erik@faust:~$  mopidy
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 5, in <module>
main()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 48, in main
options = parse_options()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 85, in parse_options
help='show GStreamer help options')
File "/usr/lib64/python2.6/optparse.py", line 1012, in add_option
raise TypeError, "invalid arguments"
TypeError: invalid arguments
erik@faust:~$  python --version
Python 2.6
erik@faust:~$  uname -a
Linux faust 3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
erik@faust:~$  cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
erik@faust:~$

# Fixed code
def __init__(self, core):
    super(MpdFrontend, self).__init__()
    hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
    port = settings.MPD_SERVER_PORT

    # NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
    # See https://github.com/mopidy/mopidy/issues/302 for details.
    try:
        network.Server(
            hostname,
            port,
            protocol=session.MpdSession,
            protocol_kwargs={b"core": core},
            max_connections=settings.MPD_SERVER_MAX_CONNECTIONS,
            timeout=settings.MPD_SERVER_CONNECTION_TIMEOUT,
        )
    except IOError as error:
        logger.error("MPD server startup failed: %s", encoding.locale_decode(error))
        sys.exit(1)

    logger.info("MPD server running at [%s]:%s", hostname, port)
# Buggy code
def decorator(func):
    match = re.search("([a-z_]+)", pattern)
    if match is not None:
        mpd_commands.add(MpdCommand(name=match.group(), auth_required=auth_required))
    # NOTE: Make pattern a bytestring to get bytestring keys in the dict
    # returned from matches.groupdict(), which is again used as a **kwargs
    # dict. This is needed to work on Python < 2.6.5. See
    # https://github.com/mopidy/mopidy/issues/302 for details.
    bytestring_pattern = pattern.encode("utf-8")
    compiled_pattern = re.compile(bytestring_pattern, flags=re.UNICODE)
    if compiled_pattern in request_handlers:
        raise ValueError("Tried to redefine handler for %s with %s" % (pattern, func))
    request_handlers[compiled_pattern] = func
    func.__doc__ = "    - *Pattern:* ``%s``\n\n%s" % (pattern, func.__doc__ or "")
    return func


# Traceback (TypeError)
erik@faust:~$  mopidy
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 5, in <module>
main()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 48, in main
options = parse_options()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 85, in parse_options
help='show GStreamer help options')
File "/usr/lib64/python2.6/optparse.py", line 1012, in add_option
raise TypeError, "invalid arguments"
TypeError: invalid arguments
erik@faust:~$  python --version
Python 2.6
erik@faust:~$  uname -a
Linux faust 3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
erik@faust:~$  cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
erik@faust:~$

# Fixed code
def decorator(func):
    match = re.search("([a-z_]+)", pattern)
    if match is not None:
        mpd_commands.add(MpdCommand(name=match.group(), auth_required=auth_required))
    # NOTE Make pattern a bytestring to get bytestring keys in the dict
    # returned from matches.groupdict(), which is again used as a **kwargs
    # dict. This is needed to work on Python < 2.6.5.
    # See https://github.com/mopidy/mopidy/issues/302 for details.
    bytestring_pattern = pattern.encode("utf-8")
    compiled_pattern = re.compile(bytestring_pattern, flags=re.UNICODE)
    if compiled_pattern in request_handlers:
        raise ValueError("Tried to redefine handler for %s with %s" % (pattern, func))
    request_handlers[compiled_pattern] = func
    func.__doc__ = "    - *Pattern:* ``%s``\n\n%s" % (pattern, func.__doc__ or "")
    return func
# Buggy code
def copy(self, **values):
    """
    Copy the model with ``field`` updated to new value.

    Examples::

        # Returns a track with a new name
        Track(name='foo').copy(name='bar')
        # Return an album with a new number of tracks
        Album(num_tracks=2).copy(num_tracks=5)

    :param values: the model fields to modify
    :type values: dict
    :rtype: new instance of the model being copied
    """
    data = {}
    for key in self.__dict__.keys():
        public_key = key.lstrip("_")
        data[public_key] = values.pop(public_key, self.__dict__[key])
    for key in values.keys():
        if hasattr(self, key):
            data[key] = values.pop(key)
    if values:
        raise TypeError('copy() got an unexpected keyword argument "%s"' % key)
    return self.__class__(**data)


# Traceback (TypeError)
erik@faust:~$  mopidy
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 5, in <module>
main()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 48, in main
options = parse_options()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 85, in parse_options
help='show GStreamer help options')
File "/usr/lib64/python2.6/optparse.py", line 1012, in add_option
raise TypeError, "invalid arguments"
TypeError: invalid arguments
erik@faust:~$  python --version
Python 2.6
erik@faust:~$  uname -a
Linux faust 3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
erik@faust:~$  cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
erik@faust:~$

# Fixed code
def copy(self, **values):
    """
    Copy the model with ``field`` updated to new value.

    Examples::

        # Returns a track with a new name
        Track(name='foo').copy(name='bar')
        # Return an album with a new number of tracks
        Album(num_tracks=2).copy(num_tracks=5)

    :param values: the model fields to modify
    :type values: dict
    :rtype: new instance of the model being copied
    """
    # NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
    # See https://github.com/mopidy/mopidy/issues/302 for details
    data = {}
    for key in self.__dict__.keys():
        public_key = key.lstrip("_")
        data[str(public_key)] = values.pop(public_key, self.__dict__[key])
    for key in values.keys():
        if hasattr(self, key):
            data[str(key)] = values.pop(key)
    if values:
        raise TypeError('copy() got an unexpected keyword argument "%s"' % key)
    return self.__class__(**data)
# Buggy code
def __init__(self, *args, **kwargs):
    self.__dict__["artists"] = frozenset(kwargs.pop("artists", []))
    super(Album, self).__init__(*args, **kwargs)


# Traceback (TypeError)
erik@faust:~$  mopidy
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 5, in <module>
main()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 48, in main
options = parse_options()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 85, in parse_options
help='show GStreamer help options')
File "/usr/lib64/python2.6/optparse.py", line 1012, in add_option
raise TypeError, "invalid arguments"
TypeError: invalid arguments
erik@faust:~$  python --version
Python 2.6
erik@faust:~$  uname -a
Linux faust 3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
erik@faust:~$  cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
erik@faust:~$

# Fixed code
def __init__(self, *args, **kwargs):
    # NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
    # See https://github.com/mopidy/mopidy/issues/302 for details
    self.__dict__[b"artists"] = frozenset(kwargs.pop("artists", []))
    super(Album, self).__init__(*args, **kwargs)
# Buggy code
def __init__(self, *args, **kwargs):
    self.__dict__["artists"] = frozenset(kwargs.pop("artists", []))
    super(Track, self).__init__(*args, **kwargs)


# Traceback (TypeError)
erik@faust:~$  mopidy
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 5, in <module>
main()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 48, in main
options = parse_options()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 85, in parse_options
help='show GStreamer help options')
File "/usr/lib64/python2.6/optparse.py", line 1012, in add_option
raise TypeError, "invalid arguments"
TypeError: invalid arguments
erik@faust:~$  python --version
Python 2.6
erik@faust:~$  uname -a
Linux faust 3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
erik@faust:~$  cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
erik@faust:~$

# Fixed code
def __init__(self, *args, **kwargs):
    # NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
    # See https://github.com/mopidy/mopidy/issues/302 for details
    self.__dict__[b"artists"] = frozenset(kwargs.pop("artists", []))
    super(Track, self).__init__(*args, **kwargs)
# Buggy code
def __init__(self, *args, **kwargs):
    if len(args) == 2 and len(kwargs) == 0:
        kwargs["tlid"] = args[0]
        kwargs["track"] = args[1]
        args = []
    super(TlTrack, self).__init__(*args, **kwargs)


# Traceback (TypeError)
erik@faust:~$  mopidy
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 5, in <module>
main()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 48, in main
options = parse_options()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 85, in parse_options
help='show GStreamer help options')
File "/usr/lib64/python2.6/optparse.py", line 1012, in add_option
raise TypeError, "invalid arguments"
TypeError: invalid arguments
erik@faust:~$  python --version
Python 2.6
erik@faust:~$  uname -a
Linux faust 3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
erik@faust:~$  cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
erik@faust:~$

# Fixed code
def __init__(self, *args, **kwargs):
    # NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
    # See https://github.com/mopidy/mopidy/issues/302 for details
    if len(args) == 2 and len(kwargs) == 0:
        kwargs[b"tlid"] = args[0]
        kwargs[b"track"] = args[1]
        args = []
    super(TlTrack, self).__init__(*args, **kwargs)
# Buggy code
def __init__(self, *args, **kwargs):
    self.__dict__["tracks"] = tuple(kwargs.pop("tracks", []))
    super(Playlist, self).__init__(*args, **kwargs)


# Traceback (TypeError)
erik@faust:~$  mopidy
Traceback (most recent call last):
File "/usr/local/bin/mopidy", line 5, in <module>
main()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 48, in main
options = parse_options()
File "/usr/local/lib64/python2.6/site-packages/mopidy/__main__.py", line 85, in parse_options
help='show GStreamer help options')
File "/usr/lib64/python2.6/optparse.py", line 1012, in add_option
raise TypeError, "invalid arguments"
TypeError: invalid arguments
erik@faust:~$  python --version
Python 2.6
erik@faust:~$  uname -a
Linux faust 3.0.13-0.27-default #1 SMP Wed Feb 15 13:33:49 UTC 2012 (d73692b) x86_64 x86_64 x86_64 GNU/Linux
erik@faust:~$  cat /etc/SuSE-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2
erik@faust:~$

# Fixed code
def __init__(self, *args, **kwargs):
    # NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
    # See https://github.com/mopidy/mopidy/issues/302 for details
    self.__dict__[b"tracks"] = tuple(kwargs.pop("tracks", []))
    super(Playlist, self).__init__(*args, **kwargs)