Mercurial > cpython-lru_cache-weakref
diff Lib/lib-old/codehack.py @ 723:e7571a18bdef legacy-trunk
Add a function to return just the line number of a code object.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 27 Mar 1992 15:13:08 +0000 |
| parents | a0d4c5ef1d5d |
| children | 1940892d2fe3 |
line wrap: on
line diff
--- a/Lib/lib-old/codehack.py Fri Mar 27 15:12:43 1992 +0000 +++ b/Lib/lib-old/codehack.py Fri Mar 27 15:13:08 1992 +0000 @@ -52,3 +52,12 @@ def getfuncname(func): return getcodename(func.func_code) + +# A part of the above code to extract just the line number from a code object. + +def getlineno(co): + code = co.co_code + if ord(code[0]) == SET_LINENO: + return ord(code[1]) | ord(code[2]) << 8 + else: + return -1
