Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
50d735fc
Commit
50d735fc
authored
May 11, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update inspect to better match how we represent builtin functions
parent
42218c87
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
from_cpython/Lib/inspect.py
from_cpython/Lib/inspect.py
+5
-0
test/tests/inspect_test.py
test/tests/inspect_test.py
+13
-0
No files found.
from_cpython/Lib/inspect.py
View file @
50d735fc
...
...
@@ -818,6 +818,11 @@ def getargspec(func):
func
=
func
.
im_func
if
not
isfunction
(
func
):
raise
TypeError
(
'{!r} is not a Python function'
.
format
(
func
))
# Pyston change: many of our builtin functions are of type FunctionType, but
# don't have full introspection available. I think this check catches most of them,
# though I think it allows some cases that CPython does not:
if
func
.
func_code
.
co_argcount
>
len
(
func
.
func_code
.
co_varnames
):
raise
TypeError
(
'{!r} is not a Python function'
.
format
(
func
))
args
,
varargs
,
varkw
=
getargs
(
func
.
func_code
)
return
ArgSpec
(
args
,
varargs
,
varkw
,
func
.
func_defaults
)
...
...
test/tests/inspect_test.py
View file @
50d735fc
...
...
@@ -5,8 +5,21 @@ def f1(a, b=2, *args, **kw):
def
f2
():
pass
class
C
(
object
):
def
__init__
(
self
):
pass
class
D
(
object
):
pass
print
inspect
.
getargspec
(
f1
)
print
inspect
.
getargspec
(
f2
)
print
inspect
.
getargspec
(
C
.
__init__
)
print
inspect
.
getargspec
(
C
().
__init__
)
try
:
print
inspect
.
getargspec
(
D
.
__init__
)
except
Exception
as
e
:
print
type
(
e
)
def
G
():
yield
1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment