[issue42116] Inspect library ignore comments at the end of a function (inspect.getsource)

Gold Games report at bugs.python.org
Thu Oct 22 06:48:44 EDT 2020


New submission from Gold Games <noureddine.hamid at usmba.ac.ma>:

inspect.getsource ignore comments at the end of the function:

for example this function:

def matmul_single(A, x, out):
  from numpy import matmul
  out[:] = matmul(A, x)
  # Some comment here...

using the inspect library:
>>> inspect.getsource(matmul_single)                                                                                                                                     
>>> "def omp_matmul_single(A, x, out):\n  from numpy import matmul\n out[:] = matmul(A, x)\n"

the result does not contain the comments at the end of the function.

----------
components: Library (Lib)
messages: 379289
nosy: noureddine.hamid
priority: normal
severity: normal
status: open
title: Inspect library ignore comments at the end of a function (inspect.getsource)
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42116>
_______________________________________


More information about the Python-bugs-list mailing list