Bug 2024322 - Python 3.9.8 regression with argparse: upstream issue 45235: argparse does not preserve namespace with subparser defaults
Summary: Python 3.9.8 regression with argparse: upstream issue 45235: argparse does no...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: python3.9
Version: 9.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Charalampos Stratakis
QA Contact: Lukáš Zachar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-11-17 20:10 UTC by John Sefler
Modified: 2022-05-17 15:38 UTC (History)
3 users (show)

Fixed In Version: python3.9-3.9.9-1.el9
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-17 15:36:22 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github python cpython pull 29531 0 None Merged [3.9] bpo-45235: Revert an argparse bugfix that caused a regression (GH-29525) 2021-11-18 15:30:51 UTC
Gitlab redhat/centos-stream/rpms python3.9 merge_requests 18 0 None None None 2021-11-18 17:28:33 UTC
Python 45235 0 None None None 2021-11-18 15:30:51 UTC
Red Hat Issue Tracker RHELPLAN-103082 0 None None None 2021-11-17 20:11:10 UTC
Red Hat Product Errata RHBA-2022:3899 0 None None None 2022-05-17 15:36:37 UTC

Description John Sefler 2021-11-17 20:10:16 UTC
Description of problem:
A recent change in the RHEL 9 nightly composes has introduced an upgrade from python3-3.9.6-6.el9 to python3-3.9.8-1.el9.  Oddly (or coincidentally?), this change appears to affect the subscription-manager sypurpose submodule commands that attempt to list available purposes through a proxy.  The proxy appears to be ignored.  However, the same commands without syspurpose respects the proxy as expected.


Version-Release number of selected component (if applicable):
[root@kvm-02-guest14 ~]# rpm -q subscription-manager
subscription-manager-1.29.21-1.el9.x86_64


How reproducible:
Only happens when new python3-3.9.8-1.el9 is installed
Does NOT happen on RHEL9 Beta compose with python3-3.9.6-6.el9 is installed
Does NOT happen on RHEL8 with the latest subscription-manager-1.28.23-1

Steps to Reproduce:
UNREGISTERED WITHOUT ANY ENVIRONMENT VARIABLES SET FOR PROXY 
[root@kvm-02-guest14 ~]# rpm -q subscription-manager python3
subscription-manager-1.29.21-1.el9.x86_64
python3-3.9.8-1.el9.x86_64
[root@kvm-02-guest14 ~]# subscription-manager config --logging.default_log_level=DEBUG
[root@kvm-02-guest14 ~]# 
[root@kvm-02-guest14 ~]# subscription-manager role --list --username=testuser1 --password=password --org=admin --proxy=bad-proxy:3129
Proxy connection failed, please check your settings.    <========== THIS IS WORKING AS EXPECTED
[root@kvm-02-guest14 ~]# 
[root@kvm-02-guest14 ~]# subscription-manager syspurpose role --list --username=testuser1 --password=password --org=admin --proxy=bad-proxy:3129
+-------------------------------------------+           <========== THIS IS NOT EXPECTED
               Available role
+-------------------------------------------+
 - SP Starter
 - SP Server
[root@kvm-02-guest14 ~]#

FAILEDQA: Notice above that the only difference in the two commands is the "syspurpose" module and the expected results should be the same... "Proxy connection failed, please check your settings."

----------------------------------------------

Without showing all the details, the rhsm.log file shows that the first command builds a connection with the bad-proxy...
 
2021-11-17 14:37:50,717 [DEBUG] subscription-manager:371730:MainThread @connection.py:269 - Connection built: http_proxy=bad-proxy:3129 host=rhsm-auto85-candlepin.usersys.redhat.com port=8443 handler=/candlepin auth=identity_cert ca_dir=/etc/rhsm/ca/ insecure=False

and the second command does not use the proxy argument when building a connection...

2021-11-17 14:38:16,557 [DEBUG] subscription-manager:371741:MainThread @connection.py:269 - Connection built: host=rhsm-auto85-candlepin.usersys.redhat.com port=8443 handler=/candlepin auth=identity_cert ca_dir=/etc/rhsm/ca/ insecure=False

----------------------------------------------

Additional info:

Now let's downgrade back to an older python3 and see what happens on the exact same system with the exact same subscription-manager package installed with the same rhsm.conf settings....

[root@kvm-02-guest14 ~]# rpm -q subscription-manager python3
subscription-manager-1.29.21-1.el9.x86_64
python3-3.9.8-1.el9.x86_64
[root@kvm-02-guest14 ~]# 
[root@kvm-02-guest14 ~]# yum downgrade python3* --exclude python3-subscription-manager* --exclude python3-cloud-what enablerepo=beaker* --quiet
Is this ok [y/N]: y

Downgraded:
  audit-3.0.5-3.el9_b.x86_64                                                          
  audit-libs-3.0.5-3.el9_b.x86_64                                                     
  dnf-4.7.0-2.el9.noarch                                                              
  dnf-data-4.7.0-2.el9.noarch                                                         
  dnf-plugins-core-4.0.21-3.el9_b.noarch                                              
  libcomps-0.1.16-4.el9.x86_64                                                        
  libdnf-0.63.0-5.el9_b.x86_64                                                        
  librepo-1.14.0-6.el9.x86_64                                                         
  libselinux-3.2-6.el9.x86_64                                                         
  libselinux-utils-3.2-6.el9.x86_64                                                   
  libsemanage-3.2-4.el9.x86_64                                                        
  nftables-1:0.9.8-7.el9.x86_64                                                       
  policycoreutils-3.2-8.el9_b.x86_64                                                  
  policycoreutils-python-utils-3.2-8.el9_b.noarch                                     
  python-unversioned-command-3.9.6-6.el9.noarch                                       
  python3-3.9.6-6.el9.x86_64                                                          
  python3-audit-3.0.5-3.el9_b.x86_64                                                  
  python3-dnf-4.7.0-2.el9.noarch                                                      
  python3-dnf-plugins-core-4.0.21-3.el9_b.noarch                                      
  python3-hawkey-0.63.0-5.el9_b.x86_64                                                
  python3-libcomps-0.1.16-4.el9.x86_64                                                
  python3-libdnf-0.63.0-5.el9_b.x86_64                                                
  python3-librepo-1.14.0-6.el9.x86_64                                                 
  python3-libs-3.9.6-6.el9.x86_64                                                     
  python3-libselinux-3.2-6.el9.x86_64                                                 
  python3-libsemanage-3.2-4.el9.x86_64                                                
  python3-nftables-1:0.9.8-7.el9.x86_64                                               
  python3-pip-21.0.1-6.el9.noarch                                                     
  python3-policycoreutils-3.2-8.el9_b.noarch                                          
  python3-psutil-5.8.0-9.el9.x86_64                                                   
  yum-4.7.0-2.el9.noarch                                                              
  yum-utils-4.0.21-3.el9_b.noarch                                                     

[root@kvm-02-guest14 ~]# rpm -q subscription-manager python3
subscription-manager-1.29.21-1.el9.x86_64
python3-3.9.6-6.el9.x86_64
[root@kvm-02-guest14 ~]# 
[root@kvm-02-guest14 ~]# subscription-manager role --list --username=testuser1 --password=password --org=admin --proxy=bad-proxy:3129
Proxy connection failed, please check your settings.    <============= THIS IS WORKING AS EXPECTED
[root@kvm-02-guest14 ~]# 
[root@kvm-02-guest14 ~]# subscription-manager syspurpose role --list --username=testuser1 --password=password --org=admin --proxy=bad-proxy:3129
Proxy connection failed, please check your settings.    <============= THIS IS WORKING AS EXPECTED
[root@kvm-02-guest14 ~]# 

PASSED: When python3-3.9.6-6.el9.x86_64 is running, both commands are in sync and throw a proxy connection exception on a bad proxy as expected.

----------------------------------------------


Since this failure was revealed by a gating test and appears to be a flaw in a dependent package rather than subscription-manager-1.29.21-1.el9 itself, I will impose a temporary workaround while this bugzilla is open to get past gating.

Comment 1 Pino Toscano 2021-11-18 15:30:52 UTC
This is actually a Python 3.9.8 regression, and precisely it is: https://bugs.python.org/issue45235
In particular, this was fixed with the upstream PR https://github.com/python/cpython/pull/29531

I tried John's instructions; then I hot-patched python3 with the upstream fix for the aforementioned bug:
# wget https://github.com/python/cpython/commit/587ff7f50bcbfd8346c6d5db459a1628a350c04d.diff
# filterdiff -i '*/argparse.py' /home/pino/587ff7f50bcbfd8346c6d5db459a1628a350c04d.diff | patch -p2 -F3 /usr/lib64/python3.9/argparse.py
With this, subscription-manager works again as it used to before the upgrade to 3.9.8.

@Python maintainers: I added the "Regression" keyword as this new Python version causes a regression in working software.
Can you please prioritize this fix? Thanks in advance!

Comment 2 Pino Toscano 2021-11-18 15:33:19 UTC
An alternative to the backport of this bug fix could be the rebase to Python 3.9.9, released 3 days ago, that contains the fix for this regression as well.

Comment 12 errata-xmlrpc 2022-05-17 15:36:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: python3.9), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:3899


Note You need to log in before you can comment on or make changes to this bug.