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

Readfile: Fix exception type for STDIN reading #218

Merged
merged 1 commit into from Jan 5, 2020

Conversation

aureliojargas
Copy link
Member

This specific line was introduced in txt2tags version 1.0, from 2002. By
that time, every exception used to have Exception as the root class,
so this used to work for the use-case of hitting Control-C when txt2tags
seemed frozen (but in fact was just waiting for data in STDIN).

In recent Python 2.7 and 3.x, KeyboardInterrupt is derived from
BaseException instead, so this is not catching Control-C anymore.

The fix is simple: use the specific KeyboardInterrupt exception
instead of a generic one (sorry, in 2002 I did not know better).

This specific line was introduced in txt2tags version 1.0, from 2002. By
that time, every exception used to have `Exception` as the root class,
so this used to work for the use-case of hitting Control-C when txt2tags
seemed frozen (but in fact was just waiting for data in STDIN).

In recent Python 2.7 and 3.x, `KeyboardInterrupt` is derived from
`BaseException` instead, so this is not catching Control-C anymore.

The fix is simple: use the specific `KeyboardInterrupt` exception
instead of a generic one (sorry, in 2002 I did not know better).
@jendrikseipp jendrikseipp merged commit 2db99dd into txt2tags:v3 Jan 5, 2020
@jendrikseipp
Copy link

Thanks for the fix!

@aureliojargas aureliojargas deleted the control-c branch January 5, 2020 20:11
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.

None yet

2 participants