Skip to content

MySQLdb exceptions should reflect their public API name in tracebacks #522

Closed
@metzen

Description

@metzen

Currently, the exception types used by MySQLdb are defined within the MySQLdb._exceptions submodule, but are also aliased as symbols within the MySQLdb._mysql C extension module, as well as imported from there to be exposed in the top level MySQLdb package, where they are intended to be used by clients.

However, when one of these exceptions is raised by the MySQLdb implementation, the name which is depicted in the resulting traceback will reference the original definition location of the exception in MySQLdb._exceptions, e.g.,

MySQLdb._exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax ...")

When users encounter such an error, they may be inclined to use the name as it is depicted in the traceback when attempting to add exception catching behavior for the error rather than the intended public alias in MySQLdb.ProgrammingError (if they are not aware that this is provided).

It would be prudent to steer users in the right direction by avoiding this private submodule exposure and having the name used in tracebacks reflect the intended public interface for referencing the symbol.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions