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

Created on 2018-03-22 13:36 by peterdemin, last changed 2018-07-15 19:25 by ppperry. 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

inspect.unwrap has loop protection against functions that wrap themselves, but 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
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\", line 3, in <module>
  File "C:\Programs\Python37\lib\", line 515, in unwrap
    raise ValueError('wrapper loop when unwrapping {!r}'.format(f))
ValueError: wrapper loop when unwrapping call
Date User Action Args
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

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