fix for ticket 1829: http://projects.scipy.org/scipy/ticket/1829