Bug 1785607

Summary: Package packages is no longer available - import produces AttributeError
Product: Red Hat Enterprise Linux 7 Reporter: Pavol Babinčák <pbabinca>
Component: python-requestsAssignee: Charalampos Stratakis <cstratak>
Status: CLOSED ERRATA QA Contact: RHEL CS Apps Subsystem QE <rhel-cs-apps-subsystem-qe>
Severity: unspecified Docs Contact:
Priority: high    
Version: 7.7CC: cstratak, hhorak, jcastran, jesusr, jhouska, pviktori, python-maint, redhat, sbradley, wchadwic
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-requests-2.6.0-10.el7 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 1811048 1811049 1811050 1811051 (view as bug list) Environment:
Last Closed: 2020-09-29 19:39:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1811048, 1811049, 1811050, 1811051    

Description Pavol Babinčák 2019-12-20 12:43:47 UTC
Description of problem:
Recent change to python-requests broke interface that is used in many code bases. Previously top level requests packages could have been imported and package "packages" was made available. Code that is used in large amount of projects over the internet (e.g. https://programtalk.com/python-examples/requests.packages.urllib3.disable_warnings/ ) now fails on exception AttributeError. 

Version-Release number of selected component (if applicable):
python-requests-2.6.0-8.el7_7

How reproducible:
Always

Steps to Reproduce:
1. Run code python -c 'import requests; requests.packages'
2.
3.

Actual results:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'packages'


Expected results:

No traceback and package "packages" is available in a followup code. 

Additional info:

Comment 2 Miro Hrončok 2019-12-20 13:05:00 UTC
While this was probably never a documented API, it is indeed used in the wild and removing it breaks things. Upstream added this hideous hack to have it back:

https://github.com/psf/requests/blob/v2.18.0/requests/packages.py

Comment 5 Petr Viktorin (pviktori) 2020-01-28 14:51:50 UTC
We are planning to make `import requests.packages` possible and safe.
However, `import requests; requests.packages` will not be possible without significant slowdown for everyone who imports requests.

Will that be OK for you? The code seems fixed on your side.

Comment 6 Pavol Babinčák 2020-02-07 08:37:07 UTC
(In reply to Petr Viktorin from comment #5)
> We are planning to make `import requests.packages` possible and safe.
> However, `import requests; requests.packages` will not be possible without
> significant slowdown for everyone who imports requests.
> 
> Will that be OK for you? The code seems fixed on your side.

I guess it is your call. I cannot speak for everyone.

Comment 19 Richard 2020-04-10 07:51:56 UTC
We had the same issue: code breaking because requests.packages.urllib3.disable_warnings() was suddenly no longer available after an upgrade. It took me a long time to find this bug report. Is this at al related to https://access.redhat.com/errata/RHBA-2020:0781 ? Because it looks like it is fixed now.

Comment 20 Petr Viktorin (pviktori) 2020-04-14 08:37:55 UTC
Yes, RHBA-2020:0781 has the fix for RHEL 7.5, 7.6 and 7.7.

This bug tracks inclusion of the fix in future RHEL7 versions.

Comment 21 Jan Houska 2020-05-22 11:25:34 UTC
VERIFIED 


NEW PASS:
python-requests-2.6.0-10.el7.noarch



# rpm -qa python-requests
python-requests-2.6.0-10.el7.noarch

# python -c 'import requests; requests.packages'
# echo $?
0





OLD FAIL:
python-requests-2.6.0-8.el7_7.noarch


# rpm -qa python-requests
python-requests-2.6.0-8.el7_7.noarch

# python -c 'import requests; requests.packages'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'packages'
# echo $?
1

Comment 23 errata-xmlrpc 2020-09-29 19:39:41 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 (python-requests bug fix and enhancement update), 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-2020:3886