# Buggy code
def fromroots(cls, roots, domain=[], window=None):
    """Return series instance that has the specified roots.

    Returns a series representing the product
    ``(x - r[0])*(x - r[1])*...*(x - r[n-1])``, where ``r`` is a
    list of roots.

    Parameters
    ----------
    roots : array_like
        List of roots.
    domain : {[], None, array_like}, optional
        Domain for the resulting series. If None the domain is the
        interval from the smallest root to the largest. If [] the
        domain is the class domain. The default is [].
    window : {None, array_like}, optional
        Window for the returned series. If None the class window is
        used. The default is None.

    Returns
    -------
    new_series : series
        Series with the specified roots.

    """
    [roots] = pu.as_series([roots], trim=False)
    if domain is None:
        domain = pu.getdomain(roots)
    elif domain == []:
        domain = cls.domain

    if window is None:
        window = cls.window

    deg = len(roots)
    off, scl = pu.mapparms(domain, window)
    rnew = off + scl * roots
    coef = cls._fromroots(rnew) / scl**deg
    return cls(coef, domain=domain, window=window)


# Traceback (UnboundLocalError)
In [1]: import numpy.polynomial.polynomial as npp

In [2]: p1 = npp.Polynomial([1,2])

In [3]: p2 = npp.Polynomial([3,4])

In [4]: npp.polydiv(p1, p2)
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-4-00c25f56fb20> in <module>()
----> 1 npp.polydiv(p1, p2)

/Users/warren/anaconda/lib/python2.7/site-packages/numpy/polynomial/polynomial.pyc in polydiv(c1, c2)
406     len2 = len(c2)
407     if len2 == 1 :
--> 408         return c1/c2[-1], c1[:1]*0
409     elif len1 < len2 :
410         return c1[:1]*0, c1

/Users/warren/anaconda/lib/python2.7/site-packages/numpy/polynomial/polynomial.pyc in __rtruediv__(self, other)

UnboundLocalError: local variable 'quo' referenced before assignment

# Fixed code
def fromroots(cls, roots, domain=[], window=None):
    """Return series instance that has the specified roots.

    Returns a series representing the product
    ``(x - r[0])*(x - r[1])*...*(x - r[n-1])``, where ``r`` is a
    list of roots.

    Parameters
    ----------
    roots : array_like
        List of roots.
    domain : {[], None, array_like}, optional
        Domain for the resulting series. If None the domain is the
        interval from the smallest root to the largest. If [] the
        domain is the class domain. The default is [].
    window : {None, array_like}, optional
        Window for the returned series. If None the class window is
        used. The default is None.

    Returns
    -------
    new_series : series
        Series with the specified roots.

    """
    [roots] = pu.as_series([roots], trim=False)
    if domain is None:
        domain = pu.getdomain(roots)
    elif isinstance(domain, list) and len(domain) == 0:
        domain = cls.domain

    if window is None:
        window = cls.window

    deg = len(roots)
    off, scl = pu.mapparms(domain, window)
    rnew = off + scl * roots
    coef = cls._fromroots(rnew) / scl**deg
    return cls(coef, domain=domain, window=window)