Public bug reported:

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

** Affects: python-apt (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1930584

Title:
  InstallProgress is not being used as a context manager

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-apt/+bug/1930584/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to