[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread miss-islington


miss-islington  added the comment:


New changeset 07ab490a7a966ce00a61bf56ccd0604434b143a5 by Miss Islington (bot) 
in branch '3.8':
bpo-43316: gzip: Fix sys.exit() usage. (GH-24652)
https://github.com/python/cpython/commit/07ab490a7a966ce00a61bf56ccd0604434b143a5


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread miss-islington


miss-islington  added the comment:


New changeset 540749ed6d8e29a11368bc7f343baf7b7ea7e4a8 by Miss Islington (bot) 
in branch '3.9':
bpo-43316: gzip: Fix sys.exit() usage. (GH-24652)
https://github.com/python/cpython/commit/540749ed6d8e29a11368bc7f343baf7b7ea7e4a8


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23439
pull_request: https://github.com/python/cpython/pull/24654

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23438
pull_request: https://github.com/python/cpython/pull/24653

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset 9525a18b5bb317d9fb206c992ab62aa41559b0c8 by Inada Naoki in branch 
'master':
bpo-43316: gzip: Fix sys.exit() usage. (GH-24652)
https://github.com/python/cpython/commit/9525a18b5bb317d9fb206c992ab62aa41559b0c8


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset adea9b86a97794ca75054603497c195d5ba39aa5 by Miss Islington (bot) 
in branch '3.9':
bpo-43316:  gzip: CLI uses non-zero return code on error. (GH-24647)
https://github.com/python/cpython/commit/adea9b86a97794ca75054603497c195d5ba39aa5


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread Inada Naoki


Change by Inada Naoki :


--
pull_requests: +23437
pull_request: https://github.com/python/cpython/pull/24652

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread miss-islington


miss-islington  added the comment:


New changeset 69906c505b139cbd892866dbceeb607eff53ab3b by Miss Islington (bot) 
in branch '3.8':
bpo-43316:  gzip: CLI uses non-zero return code on error. (GH-24647)
https://github.com/python/cpython/commit/69906c505b139cbd892866dbceeb607eff53ab3b


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +23433
pull_request: https://github.com/python/cpython/pull/24648

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23434
pull_request: https://github.com/python/cpython/pull/24649

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset cc3df6368d4f3f6c9c9b716876c7e7b79c7abf3f by Ruben Vorderman in 
branch 'master':
bpo-43316:  gzip: CLI uses non-zero return code on error. (GH-24647)
https://github.com/python/cpython/commit/cc3df6368d4f3f6c9c9b716876c7e7b79c7abf3f


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread Ruben Vorderman


Change by Ruben Vorderman :


--
keywords: +patch
pull_requests: +23432
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24647

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread Ruben Vorderman


Ruben Vorderman  added the comment:

That sounds perfect, I didn't think of that. I will make a PR.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-25 Thread Inada Naoki


Inada Naoki  added the comment:

I prefer `sys.exit("message")`.

--
nosy: +methane

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-24 Thread Ruben Vorderman


Change by Ruben Vorderman :


--
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43316] python -m gzip handles error incorrectly

2021-02-24 Thread Ruben Vorderman


New submission from Ruben Vorderman :

`Python -m gzip -d myfile` will throw an error because myfile does not end in 
'.gz'. That is fair (even though a bit redundant, GzipFile contains a header 
check, so why bother checking the extension?).

The problem is how this error is thrown.
1. Error is printed to stdout instead of stderr
2. Tool exits with exit 0.

This is not the behaviour that is expected when using python -m gzip in a 
script.

The error is even codified in a test: 
https://github.com/python/cpython/blob/1f433406bd46fbd00b88223ad64daea6bc9eaadc/Lib/test/test_gzip.py#L776

def test_decompress_infile_outfile_error(self):
rc, out, err = assert_python_ok('-m', 'gzip', '-d', 'thisisatest.out')
self.assertIn(b"filename doesn't end in .gz:", out)
self.assertEqual(rc, 0)
self.assertEqual(err, b'')

This should be assert_python_failure, out and err should be swapped, and exit 
code should be something different than 0.

>From the zen of python: Errors should never pass silently.

I am willing to fix this in a PR, but first I would like some feedback on how 
to solve this exactly. 

I propose raising a ValueError("can not determine output filename: 'myfile' 
does not end in '.gz'").

--
components: Library (Lib)
messages: 387622
nosy: rhpvorderman
priority: normal
severity: normal
status: open
title: python -m gzip handles error incorrectly
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com