This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: infinite loop in inspect.unwrap(unittest.mock.call)
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: out of date
Dependencies: Superseder: infinite loop when running inspect.unwrap over unittest.mock.call
View: 25532
Assigned To: Nosy List: peterdemin, ppperry, terry.reedy
Priority: normal Keywords:

Created on 2018-03-22 13:36 by peterdemin, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg314254 - (view) Author: Peter (peterdemin) Date: 2018-03-22 13:36
The following module will eat all available RAM if executed:

import inspect
import unittest.mock
print(inspect.unwrap(unittest.mock.call))

inspect.unwrap has loop protection against functions that wrap themselves, but unittest.mock.call creates new object on demand.
msg314270 - (view) Author: Peter (peterdemin) Date: 2018-03-22 16:15
I see two options to fix it:

1) add recursion depth check to inspect.wrap
2) define __wrapped__ on mock._Call so it won't go into recursion.
msg314303 - (view) Author: (ppperry) Date: 2018-03-23 11:22
This is a dupe of https://bugs.python.org/issue25532
msg314351 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-03-24 01:26
Peter, please include x.y.z version with reports (and upgrade first if possible ;-).  This was apparently fixed in #25532 last year for current versions.  With 3.6.4 and 3.7.0b2 I get
Traceback (most recent call last):
  File "F:\Python\a\tem2.py", line 3, in <module>
    print(inspect.unwrap(unittest.mock.call))
  File "C:\Programs\Python37\lib\inspect.py", line 515, in unwrap
    raise ValueError('wrapper loop when unwrapping {!r}'.format(f))
ValueError: wrapper loop when unwrapping call
History
Date User Action Args
2022-04-11 14:58:58adminsetgithub: 77301
2018-07-15 19:25:47ppperrysettype: crash -> behavior
2018-03-24 01:26:54terry.reedysetstatus: open -> closed

superseder: infinite loop when running inspect.unwrap over unittest.mock.call

nosy: + terry.reedy
messages: + msg314351
resolution: out of date
stage: resolved
2018-03-23 11:22:56ppperrysetnosy: + ppperry
messages: + msg314303
2018-03-22 16:15:31peterdeminsetmessages: + msg314270
2018-03-22 13:36:41peterdemincreate