[issue45475] gzip fails to read a gzipped file (ValueError: readline of closed file)

2021-10-18 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



[issue45475] gzip fails to read a gzipped file (ValueError: readline of closed file)

2021-10-18 Thread miss-islington


miss-islington  added the comment:


New changeset 97ce855ca8ce437070424b43f5b41158685ac140 by Miss Islington (bot) 
in branch '3.10':
bpo-45475: Revert `__iter__` optimization for GzipFile, BZ2File, and LZMAFile. 
(GH-29016)
https://github.com/python/cpython/commit/97ce855ca8ce437070424b43f5b41158685ac140


--

___
Python tracker 

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



[issue45475] gzip fails to read a gzipped file (ValueError: readline of closed file)

2021-10-18 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset 0a4c82ddd34a3578684b45b76f49cd289a08740b by Inada Naoki in branch 
'main':
bpo-45475: Revert `__iter__` optimization for GzipFile, BZ2File, and LZMAFile. 
(GH-29016)
https://github.com/python/cpython/commit/0a4c82ddd34a3578684b45b76f49cd289a08740b


--

___
Python tracker 

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



[issue45475] gzip fails to read a gzipped file (ValueError: readline of closed file)

2021-10-18 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +27321
pull_request: https://github.com/python/cpython/pull/29050

___
Python tracker 

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



[issue45475] gzip fails to read a gzipped file (ValueError: readline of closed file)

2021-10-17 Thread Inada Naoki


Change by Inada Naoki :


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

___
Python tracker 

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



[issue45475] gzip fails to read a gzipped file (ValueError: readline of closed file)

2021-10-15 Thread Inada Naoki


Inada Naoki  added the comment:

>>> ll = [l for l in gzip.GzipFile(filename='data/UTF-8-test_for_gzip.txt.gz')]

This is bad code pattern because you don't close the file explicitly.
Actually, the error caused by the optimization thet iter(GzipFile) returns 
underlaying faster iterator that don't have reference to the GzipFile. So 
GzipFile.__del__ close the file.

Although this is caused by bad code pattern, I must admit this is a regression.
We need to call slow Python function for each lines instead of using fast C 
iterator...

--

___
Python tracker 

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



[issue45475] gzip fails to read a gzipped file (ValueError: readline of closed file)

2021-10-15 Thread Karthikeyan Singaravelan

Karthikeyan Singaravelan  added the comment:

This might be related to below commit : 

commit d2a8e69c2c605fbaa3656a5f99aa8d295f74c80e
Author: Inada Naoki 
Date:   Tue Apr 13 13:51:49 2021 +0900

bpo-43787: Add __iter__ to GzipFile, BZ2File, and LZMAFile (GH-25353)


python -m gzip README.rst
(myenv) ➜  cpython git:(main) ✗ git checkout 
d2a8e69c2c605fbaa3656a5f99aa8d295f74c80e~1 Lib/gzip.py
Updated 1 path from 2ea7c00ab4
(myenv) ➜  cpython git:(main) ✗ ./python
Python 3.11.0a1+ (heads/main:160c38df7f, Oct 15 2021, 11:25:16) [GCC 9.3.0] on 
linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gzip
>>> len([None for _ in gzip.GzipFile("README.rst.gz")])
267
>>> 
(myenv) ➜  cpython git:(main) ✗ git checkout 
d2a8e69c2c605fbaa3656a5f99aa8d295f74c80e Lib/gzip.py 
Updated 1 path from 1f9874eec6
(myenv) ➜  cpython git:(main) ✗ ./python
Python 3.11.0a1+ (heads/main:160c38df7f, Oct 15 2021, 11:25:16) [GCC 9.3.0] on 
linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gzip
>>> len([None for _ in gzip.GzipFile("README.rst.gz")])
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1, in 
ValueError: readline of closed file

--
components: +Library (Lib)
keywords: +3.10regression
nosy: +methane, xtreak

___
Python tracker 

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



[issue45475] gzip fails to read a gzipped file (ValueError: readline of closed file)

2021-10-14 Thread minstrelofc


New submission from minstrelofc :

Attempting to iterate over an opened gzip file raises a ValueError: readline of 
closed file

Behavior in Python 3.9.7:
Python 3.9.7 (default, Oct 13 2021, 09:08:19) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gzip
>>> ll = [l for l in gzip.GzipFile(filename='data/UTF-8-test_for_gzip.txt.gz')]
>>> len(ll)
300


Behavior in Python 3.10.0 (and 3.11.0a1 is the same):
Python 3.10.0 (default, Oct 13 2021, 08:53:15) [GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gzip
>>> ll = [l for l in gzip.GzipFile(filename='data/UTF-8-test_for_gzip.txt.gz')]
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1, in 
ValueError: readline of closed file


This only happens when iterating directly over the GzipFile object. Using a 
with: statement has the correct behaviour in both 3.10 and 3.11:
>>> with gzip.GzipFile(filename='UTF-8-test_for_gzip.txt.gz') as input_file:
... len(list(input_file))
... 
300

--
files: UTF-8-test_for_gzip.txt.gz
messages: 403948
nosy: minstrelofc
priority: normal
severity: normal
status: open
title: gzip fails to read a gzipped file (ValueError: readline of closed file)
type: behavior
versions: Python 3.10, Python 3.11
Added file: https://bugs.python.org/file50358/UTF-8-test_for_gzip.txt.gz

___
Python tracker 

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