[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#989389: marked as done (python3-apt's InstallProgress is not being used as a context manager)



Your message dated Wed, 2 Jun 2021 16:15:49 +0200
with message-id <20210602161338.GA721024@debian.org>
and subject line Re: Bug#989389: python3-apt's InstallProgress is not being used as a context manager
has caused the Debian Bug report #989389,
regarding python3-apt's InstallProgress is not being used as a context manager
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
989389: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=989389
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: python3-apt
Version: 2.2.0

As can be seen in the constructor, InstallProgress is designed to be
used in a 'with' in order to properly close write_stream and
status_stream:

https://git.launchpad.net/python-apt/tree/apt/progress/base.py#n163

This commit added support for using InstallProgress as a context
manager:

https://git.launchpad.net/python-apt/commit/?id=462c05b39eae5a0fa2270d329b03d4711742f20d

It also modified a test, but didn't change the way InstallProgress is
used by cache.py.

This causes Python 3 to complain that InstallProgress's constructor
leaves unclosed files:

> /usr/lib/python3.9/glob.py:123: ResourceWarning: unclosed file <_io.TextIOWrapper name=4 mode='r' encoding='UTF-8'>
>   with os.scandir(dirname) as it:
> Object allocated at (most recent call last):
>   File "/opt/thinlinc/modules/thinlinc/packageinstaller/__init__.py", lineno 33
>     OOO0o000 = globals ( ) [ IIi1i111IiII ] . Backend ( )
>   File "/opt/thinlinc/modules/thinlinc/packageinstaller/aptbackend.py", lineno 88
>     self . _aptcallback = i1Ii1i ( self )
>   File "/opt/thinlinc/modules/thinlinc/packageinstaller/aptbackend.py", lineno 31
>     super ( ) . __init__ ( )
>   File "/usr/lib/python3/dist-packages/apt/progress/base.py", lineno 164
>     self.status_stream = os.fdopen(self.statusfd, "r")  # type: io.TextIOBase # noqa
>   File "/usr/lib/python3.9/os.py", lineno 1023
>     return io.open(fd, *args, **kwargs)
> /usr/lib/python3.9/glob.py:123: ResourceWarning: unclosed file <_io.TextIOWrapper name=5 mode='w' encoding='UTF-8'>
>   with os.scandir(dirname) as it:
> Object allocated at (most recent call last):
>   File "/opt/thinlinc/modules/thinlinc/packageinstaller/__init__.py", lineno 33
>     OOO0o000 = globals ( ) [ IIi1i111IiII ] . Backend ( )
>   File "/opt/thinlinc/modules/thinlinc/packageinstaller/aptbackend.py", lineno 88
>     self . _aptcallback = i1Ii1i ( self )
>   File "/opt/thinlinc/modules/thinlinc/packageinstaller/aptbackend.py", lineno 31
>     super ( ) . __init__ ( )
>   File "/usr/lib/python3/dist-packages/apt/progress/base.py", lineno 163
>     self.write_stream = os.fdopen(self.writefd, "w")  # type: io.TextIOBase
>   File "/usr/lib/python3.9/os.py", lineno 1023
>     return io.open(fd, *args, **kwargs)


The issue was identified on Ubuntu 21.04:

> Linux ubuntu2104 5.11.0-17-generic #18-Ubuntu SMP Thu May 6 20:10:11
> UTC 2021 x86_64 x86_64 x86_64 GNU/Linux



-- 
Samuel Mannehed         Software Development
Cendio AB               https://cendio.com
Teknikringen 8          https://twitter.com/ThinLinc
583 30 Linköping        https://facebook.com/ThinLinc
Phone: +46 13 214 600

--- End Message ---
--- Begin Message ---
On Wed, Jun 02, 2021 at 02:53:57PM +0200, Samuel Mannehed wrote:
> Package: python3-apt
> Version: 2.2.0
> 
> As can be seen in the constructor, InstallProgress is designed to be
> used in a 'with' in order to properly close write_stream and
> status_stream:
> 
> https://git.launchpad.net/python-apt/tree/apt/progress/base.py#n163
> 
> This commit added support for using InstallProgress as a context
> manager:
> 
> https://git.launchpad.net/python-apt/commit/?id=462c05b39eae5a0fa2270d329b03d4711742f20d
> 
> It also modified a test, but didn't change the way InstallProgress is
> used by cache.py.

Intentionally. Production code will create its own InstallProgress
and use that in a with statement, and the existing fallback is more
than enough to satisfy the needs for proofs of concepts; whereas
adding logic to keep track of whether we created the install
progress object or the caller did, and then conditionally do
context manager magic is too involved.

-- 
debian developer - deb.li/jak | jak-linux.org - free software dev
ubuntu core developer                              i speak de, en

--- End Message ---

Reply to: