You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now exceptions are raised either as ShapefileException (dealing specifically with the Shapefile), or just a generic Exception. At some point should go through all the generic exceptions and change them to more appropriate exception types, such as ValueError, TypeError, etc.
Replacing them with more specific, more informative, subclasses of our ShapefileException would definitely improve both the code base and the UX. I've recently added a class dbfFileException(ShapefileException ).
But the suggestion as strictly stated: replacing raise ShapefileException with raise ValueError etc. would be a breaking change to our API.
Users who have enclosed calls to PyShp inside try: ... except ShapefileException:, who upgraded PyShp, would no longer suppress ShapefileExceptions (them having been changed to ValueErrors. etc.)
Users calling out to PyShp and running other code too, inside try: ... except ValueError: intending to catch some other ValueError, but let ShapefileExceptions be raised, after upgrading PyShp could now unintentionally also suppress the former ShapefileExceptions (this also occurs if we replace the exceptions with new ones that inherit from both ShapefileException and ValueError, but that would be very unusual, I don't remember ever seeing that before).
Activity
JamesParrott commentedon Jun 22, 2026
Replacing them with more specific, more informative, subclasses of our ShapefileException would definitely improve both the code base and the UX. I've recently added a
class dbfFileException(ShapefileException ).But the suggestion as strictly stated: replacing
raise ShapefileExceptionwithraise ValueErroretc. would be a breaking change to our API.Users who have enclosed calls to PyShp inside
try: ... except ShapefileException:, who upgraded PyShp, would no longer suppress ShapefileExceptions (them having been changed to ValueErrors. etc.)Users calling out to PyShp and running other code too, inside
try: ... except ValueError:intending to catch some other ValueError, but let ShapefileExceptions be raised, after upgrading PyShp could now unintentionally also suppress the former ShapefileExceptions (this also occurs if we replace the exceptions with new ones that inherit from both ShapefileException and ValueError, but that would be very unusual, I don't remember ever seeing that before).