summaryrefslogtreecommitdiffstats
path: root/Lib/lib-old
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-03-27 15:13:08 (GMT)
committerGuido van Rossum <guido@python.org>1992-03-27 15:13:08 (GMT)
commitcb7ce349e26e5c513966ff6ec6002e2f696b81f1 (patch)
tree80fdf8bd69ff3242b532e818b6f005fb5372be1f /Lib/lib-old
parentc341c62e81e3f869b9b75fb6b1213a04388406b7 (diff)
downloadcpython-cb7ce349e26e5c513966ff6ec6002e2f696b81f1.zip
cpython-cb7ce349e26e5c513966ff6ec6002e2f696b81f1.tar.gz
cpython-cb7ce349e26e5c513966ff6ec6002e2f696b81f1.tar.bz2
Add a function to return just the line number of a code object.
Diffstat (limited to 'Lib/lib-old')
-rw-r--r--Lib/lib-old/codehack.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/lib-old/codehack.py b/Lib/lib-old/codehack.py
index 8a4f611..d00d2bf 100644
--- a/Lib/lib-old/codehack.py
+++ b/Lib/lib-old/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