Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
e8cc17ab
Commit
e8cc17ab
authored
Apr 14, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix dir(obj) after implementing dir()
parent
4f05de43
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+13
-8
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
e8cc17ab
...
...
@@ -1757,21 +1757,26 @@ class TransformBuiltinMethods(EnvTransform):
if
entry
:
# not the builtin
return
node
max_args_count
=
{
'dir'
:
1
,
'locals'
:
0
}[
func_name
]
if
len
(
node
.
args
)
>
max_args_count
:
error
(
self
.
pos
,
"Builtin '%s()' called with wrong number of args, expected %d, got %d"
%
(
func_name
,
max_args_count
,
len
(
node
.
args
)))
return
node
pos
=
node
.
pos
if
func_name
==
'locals'
:
if
func_name
==
'locals'
:
if
len
(
node
.
args
)
>
0
:
error
(
self
.
pos
,
"Builtin 'locals()' called with wrong number of args, expected 0, got %d"
%
len
(
node
.
args
))
return
node
items
=
[
ExprNodes
.
DictItemNode
(
pos
,
key
=
ExprNodes
.
StringNode
(
pos
,
value
=
var
),
value
=
ExprNodes
.
NameNode
(
pos
,
name
=
var
))
for
var
in
lenv
.
entries
]
return
ExprNodes
.
DictNode
(
pos
,
key_value_pairs
=
items
)
else
:
items
=
[
ExprNodes
.
StringNode
(
pos
,
value
=
var
)
for
var
in
lenv
.
entries
]
if
len
(
node
.
args
)
>
1
:
error
(
self
.
pos
,
"Builtin 'dir()' called with wrong number of args, expected 0-1, got %d"
%
len
(
node
.
args
))
return
node
elif
len
(
node
.
args
)
==
1
:
# optimised in Builtin.py
return
node
items
=
[
ExprNodes
.
StringNode
(
pos
,
value
=
var
)
for
var
in
lenv
.
entries
]
return
ExprNodes
.
ListNode
(
pos
,
args
=
items
)
def
visit_SimpleCallNode
(
self
,
node
):
...
...
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