Kaydet (Commit) cb7ce349 authored tarafından Guido van Rossum's avatar Guido van Rossum

Add a function to return just the line number of a code object.

üst c341c62e
......@@ -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
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment