Uploaded image for project: 'MariaDB Connector/Python'
  1. MariaDB Connector/Python
  2. CONPY-331

Confusing error message when mariadb python connector is supplied with string as port argument

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Trivial
    • Resolution: Unresolved
    • 1.1.13
    • None
    • Generic
    • mysql-connector-python 9.5.0 in python 3.13.7 and 10.4.32-MariaDB on Windows 11
    • 3.13.7

    Description

      When using the mariadb python connector, you may attempt to establish a connection with code such as:

      connj = mariadb.connect(
      user=jusername,
      password=jpasswd,
      host=jhost,
      port=int(jport),
      database=jdbnam)

      If you fail to present the "port" argument as an integer, but instead use a string, you may encounter a series of error messages similar to the following:

      Traceback (most recent call last):
      File "C:\Users\User\Documents\python\demo.py", line 70, in <module>
      connj = mariadb.connect(
      File "C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-packages\mariadb_init_.py", line 147, in connect
      connection = connectionclass(*args, **kwargs)
      File "C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-packages\mariadb\connections.py", line 85, in _init_
      super()._init_(*args, **kwargs)
      TypeError: 'str' object cannot be interpreted as an integer

      In my humble opinion, it would be better if the software simply returned an error code "invalid port" or similar if the object supplied as the port argument could not be cast as an integer in the appropriate range.

      Attachments

        Activity

          People

            georg Georg Richter
            peter.talbot@petertalbot.net Peter Talbot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.