Python Migration Error: TypeError: exceptions must be old-style classes or derived from BaseException, not str
Gregory Ewing
greg.ewing at canterbury.ac.nz
Mon Oct 3 04:59:54 EDT 2011
Wong Wah Meng-R32813 wrote:
> I am migrating my application from python 1.5.2 to 2.7.1.
> Does it mean in newer python I need to migrate all my Exception to
> non-string based exception type? That's should be a lot of changes. :p
'Fraid so. You are leaping quite a lot of versions at once,
and string exceptions have been considered passe for a *long*
time. They may already have been deprecated in 1.5, I'm
not sure.
Note that in Python 3 the condition is even stricter -- old
style classes are gone, and exceptions must derive from
BaseException or some other existing exception type. So you'd
best do that now for the sake of easing migration to Python 3
in the future.
--
Greg
More information about the Python-list
mailing list