The history of a requests contains a self-reference to the history owner. The history will be endless.
Expected Result
If I traverse recursive the complete history of a requests, this will be a finally graph.
The history of a request is a tree without cycles.
R1 (history: 2)
R2 (no history)
R3 (no history)
Actual Result
If I traverse recursive the complete history of a requests, the program breaks with recursive error. RecursionError: maximum recursion depth exceeded while calling a Python object
The history contains a self-reference to the history owner.
The history of a request is a graph with a cycle.
R1 (history: 2)
R2 (no history)
R3 (history: 1)
R3 (history: 1)
R3 (history: 1)
R3 (history: 1)
R3 (history: 1)
....
id=140537834271072 history=2
index=0 id=140537834079136
index=1 id=140537834080960
id=140537834079136 history=0
id=140537834080960 history=1
index=0 id=140537834080960
id=140537834080960 history=1
index=0 id=140537834080960
id=140537834080960 history=1
index=0 id=140537834080960
id=140537834080960 history=1
index=0 id=140537834080960
....
id=140537834080960 history=1
index=0 id=140537834080960
id=140537834080960 history=1
index=0 id=140537834080960
Traceback (most recent call last):
File "/Users/andreas/PycharmProjects/cce/main.py", line 12, in <module>
history(requests.get('https://coord.info/GC8T8E8'))
File "/Users/andreas/PycharmProjects/cce/main.py", line 9, in history
history(item)
File "/Users/andreas/PycharmProjects/cce/main.py", line 9, in history
history(item)
File "/Users/andreas/PycharmProjects/cce/main.py", line 9, in history
history(item)
[Previous line repeated 993 more times]
File "/Users/andreas/PycharmProjects/cce/main.py", line 5, in history
print(f"id={id(r)} history={len(r.history)}")
RecursionError: maximum recursion depth exceeded while calling a Python object
Process finished with exit code 1
Reproduction Steps
import requests
def history(r):
print(f"id={id(r)} history={len(r.history)}")
for index, item in enumerate(r.history):
print(f"\tindex={index} id={id(item)}")
for index, item in enumerate(r.history):
history(item)
history(requests.get('https://coord.info/GC8T8E8'))
System Information
{
"chardet": {
"version": null
},
"charset_normalizer": {
"version": "2.1.1"
},
"cryptography": {
"version": ""
},
"idna": {
"version": "3.4"
},
"implementation": {
"name": "CPython",
"version": "3.9.2"
},
"platform": {
"release": "21.6.0",
"system": "Darwin"
},
"pyOpenSSL": {
"openssl_version": "",
"version": null
},
"requests": {
"version": "2.28.1"
},
"system_ssl": {
"version": "1010109f"
},
"urllib3": {
"version": "1.26.13"
},
"using_charset_normalizer": true,
"using_pyopenssl": false
}
The history of a requests contains a self-reference to the history owner. The history will be endless.
Expected Result
If I traverse recursive the complete history of a requests, this will be a finally graph.
The history of a request is a tree without cycles.
Actual Result
If I traverse recursive the complete history of a requests, the program breaks with recursive error.
RecursionError: maximum recursion depth exceeded while calling a Python objectThe history contains a self-reference to the history owner.
The history of a request is a graph with a cycle.
Reproduction Steps
System Information
{ "chardet": { "version": null }, "charset_normalizer": { "version": "2.1.1" }, "cryptography": { "version": "" }, "idna": { "version": "3.4" }, "implementation": { "name": "CPython", "version": "3.9.2" }, "platform": { "release": "21.6.0", "system": "Darwin" }, "pyOpenSSL": { "openssl_version": "", "version": null }, "requests": { "version": "2.28.1" }, "system_ssl": { "version": "1010109f" }, "urllib3": { "version": "1.26.13" }, "using_charset_normalizer": true, "using_pyopenssl": false }