summaryrefslogtreecommitdiffstats
path: root/Lib/codehack.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/codehack.py')
-rw-r--r--Lib/codehack.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/codehack.py b/Lib/codehack.py
index 8a4f611..d00d2bf 100644
--- a/Lib/codehack.py
+++ b/Lib/codehack.py
@@ -52,3 +52,12 @@ def getcodename(co):
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