Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning behaviour improvements #23

Closed
wants to merge 1 commit into from

Conversation

vtermanis
Copy link

@vtermanis vtermanis commented Jul 25, 2016

Dear mysql connector team,

Here are some improvements to the way warnings work in the library, for your consideration, as well as a couple of close()-handling ones. (Apologies for that not being a separate commit due to time constraints.)

  1. Warnings now propagated using warnings module when get_warnings is set
    (raise_on_warnings behaves the same as before)

    This I think might be useful since warnings are immediately visible, especially during development.
  2. Do not disable get_warnings if raise_on_warnings is explicitly set to False
    Given (1) I think this makes sense
  3. errors.Warning subclasses Warning
    Prerequisite for (1)
    4.errors.get\_mysql\_exception can now return warnings where appropriate
    Prerequisite for (1)
  4. cursor[cext].handle_warnings now also emits warnings, not just exceptions_
    Prerequisite for (1)
  5. Ignore "unread result" exception in cursor[_cext].close()
    If one e.g. calls cursor.execute(...) (unbuffered) and during looping over the result set an sql-unrelated exception occurs, during cursor.close() (e.g. via finally clause) the original exception will be override by the "unread result" one. I think it might make more sense to silence this exception when closing the cursor.
  6. connection.close() does not leak socket if cmd_quit fails
    2nd statement in try-except closes socket, but might not be reached if cmd_quit fails first. Have each in their own try-except instead.

- Warnings now propagated using warnings module when get_warnings is set
  (raise_on_warnings behaves the same as before)
- Do not disable get_warnings if raise_on_warnings is explicitly set to False
- errors.Warning subclasses Warning
- errors.get_mysql_exception can now return warnings where appropriate
- cursor_[cext].handle_warnings now also emits warnings, not just exceptions
- Ignore "unread result" exception in cursor[_cext].close()
- connection.close() does not leak socket if cmd_quit fails
@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
"I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
Thanks

@vtermanis
Copy link
Author

I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Your code has been assigned to an internal queue. Please follow
bug http://bugs.mysql.com/bug.php?id=82366 for updates.
Thanks

@vtermanis vtermanis deleted the warning_improvements branch July 28, 2016 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants