Skip to content

Fix bare except in _read_load_local_packet: use except Exception - #1257

Open
koteshyelamati wants to merge 1 commit into
PyMySQL:mainfrom
koteshyelamati:main
Open

Fix bare except in _read_load_local_packet: use except Exception#1257
koteshyelamati wants to merge 1 commit into
PyMySQL:mainfrom
koteshyelamati:main

Conversation

@koteshyelamati

Copy link
Copy Markdown

In _read_load_local_packet, the bare except: clause catches BaseException, which includes KeyboardInterrupt and SystemExit. This can suppress Ctrl+C interrupts and interpreter shutdown signals.

# Before
try:
    sender.send_data()
except:
    self.connection._read_packet()  # skip ok packet
    raise

# After
try:
    sender.send_data()
except Exception:
    self.connection._read_packet()  # skip ok packet
    raise

Since send_data() raises normal Exception subclasses (like OSError, IOError) and the clause re-raises anyway, except Exception: is the correct scope here. KeyboardInterrupt and SystemExit should propagate without the cleanup step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant