Use of deprecated 'imp' module

Bug #1947425 reported by Dan Bungert
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Apport
Fix Released
Medium
Unassigned
apport (Ubuntu)
Fix Released
Medium
Unassigned
Jammy
Fix Released
Medium
Unassigned

Bug Description

Impact
------

The deprecation warning is just a warning, but it clutters the output and can lead to misattributions in case something does not work as expected.

Test Case
---------

1. apt install apport
2. Execute following command:
python3 -Wonce -c "import apport.report"
3. There should be no output.

Where problems could occur
--------------------------

Except for changes to the test cases, _check_interpreted is the only consumer for the changed code. Breakage in this code paths can lead to wrongly assume that the crashing Python code is an interpreted script or not. This can lead to reports that have only ExecutablePath set (and not InterpreterPath).

Original Description
--------------------

Code using apport/report.py will see the following warning:

$ python3 -Wonce -c "import apport.report"
/usr/lib/python3/dist-packages/apport/report.py:13
  /usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import fnmatch, glob, traceback, errno, sys, atexit, locale, imp, stat

The 'imp' module is slated for removal in Python 3.12.
https://github.com/python/cpython/blob/main/Lib/imp.py#L31

Benjamin Drung (bdrung)
Changed in apport:
milestone: none → 2.22.0
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Benjamin Drung (bdrung) wrote :
Changed in apport:
status: Triaged → Fix Committed
Benjamin Drung (bdrung)
description: updated
Revision history for this message
Benjamin Drung (bdrung) wrote :
Benjamin Drung (bdrung)
Changed in apport:
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apport - 2.22.0-0ubuntu1

---------------
apport (2.22.0-0ubuntu1) kinetic; urgency=medium

  * New upstream release:
    - Replace `ProblemReport.get_date` by `ProblemReport.get_timestamp`, fixes
      regression in 2.21.0 (LP: #1978487)
    - apport-gtk: Exclude trailing dot from URL links (LP: #1978301)
    - Fix `AttributeError`: 'NoneType' object has no attribute 'write', fixes
      regression in 2.21.0 (LP: #1979211)
    - apport_python_hook: Properly handle missing modules (LP: #1774843)
    - apport_python_hook: Fix FileNotFoundError if the current directory was
      deleted (LP: #1979637)
    - apport_python_hook: Fix crash if os.getcwd() fails (LP: #1977954)
    - Replace deprecated 'imp' module (LP: #1947425)
    - whoopsie-upload-all: Fix 'EOFError' object has no attribute 'errno',
      fixes regression in 2.21.0 (LP: #1979681)
  * Fix KeyError: 'CasperMD5json'

 -- Benjamin Drung <email address hidden> Mon, 27 Jun 2022 12:03:00 +0200

Changed in apport (Ubuntu):
status: New → Fix Released
Benjamin Drung (bdrung)
description: updated
Revision history for this message
Benjamin Drung (bdrung) wrote :

Since the SRU for jammy included several fixes, I put my comment in this bug report only.

For the SRU I cherry-picked the important fixes from apport 2.21.0 and 2.22.0 to jammy. You can see the individual commits in https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/apport/log/?h=ubuntu/jammy

I had to cherry-pick several fixes for the test suite so that the test suite runs successfully during package build with sbuild and the QEMU autopkgtest runner (and not only the in the autopkgtest setup on Launchpad).

Attached a full debdiff and a debdiff which excludes the changes to the test directory.

Revision history for this message
Benjamin Drung (bdrung) wrote :
Revision history for this message
Benjamin Drung (bdrung) wrote :
Revision history for this message
Benjamin Drung (bdrung) wrote :

I uploaded a new SRU version which includes more test fixed to make the autopkgtest suite succeed on all architectures. See #1982555 for details.

Benjamin Drung (bdrung)
description: updated
Revision history for this message
Steve Langasek (vorlon) wrote : Proposed package upload rejected

An upload of apport to jammy-proposed has been rejected from the upload queue for the following reason: "contains bugfixes without bug references or test cases, does not meet SRU policy".

Benjamin Drung (bdrung)
description: updated
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Dan, or anyone else affected,

Accepted apport into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/apport/2.20.11-0ubuntu82.3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in apport (Ubuntu Jammy):
status: New → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Benjamin Drung (bdrung) wrote :

Verified for jammy:

```
(jammy)root@host:~# dpkg -s apport | grep ^Version
Version: 2.20.11-0ubuntu82.3
(jammy)root@host:~# dpkg -s python3-apport | grep ^Version
Version: 2.20.11-0ubuntu82.3
(jammy)root@host:~# python3 -Wonce -c "import apport.report"
(jammy)root@host:~#
```

tags: added: verification-done verification-done-jammy
removed: verification-needed verification-needed-jammy
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package apport - 2.20.11-0ubuntu82.3

---------------
apport (2.20.11-0ubuntu82.3) jammy; urgency=medium

  * Replace deprecated 'imp' module (LP: #1947425)
  * Fix KeyError: 'CasperMD5json' (LP: #1964828)
  * apport-kde: Fix inverse order of choices (LP: #1967965)
  * apport-unpack: Fix ValueError: ['separator'] has no binary content
    (LP: #1889443)
  * test:
    - Mock add_gdb_info calls in KDE UI tests
    - Fix KDE UI tests if whoopsie.path is disabled
    - Fix race with progress dialog in KDE UI tests
    - Run UI KDE tests again
    - Determine source package dynamically in test_run_crash_kernel
      (LP: #1992172)

 -- Benjamin Drung <email address hidden> Thu, 24 Nov 2022 12:47:19 +0100

Changed in apport (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Andreas Hasenack (ahasenack) wrote : Update Released

The verification of the Stable Release Update for apport has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Benjamin Drung (bdrung)
Changed in apport (Ubuntu):
importance: Undecided → Medium
Changed in apport (Ubuntu Jammy):
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.