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
Gwenaël Samain
cython
Commits
0a677a76
Commit
0a677a76
authored
Feb 25, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
2ef20620
dea87f8a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
5 deletions
+45
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+16
-5
tests/run/importfrom.pyx
tests/run/importfrom.pyx
+29
-0
No files found.
Cython/Compiler/Nodes.py
View file @
0a677a76
...
...
@@ -4581,7 +4581,7 @@ class FromImportStatNode(StatNode):
#
# module ImportNode
# items [(string, NameNode)]
# interned_items [(string, NameNode)]
# interned_items [(string, NameNode
, ExprNode
)]
# item PyTempNode used internally
# import_star boolean used internally
...
...
@@ -4615,9 +4615,13 @@ class FromImportStatNode(StatNode):
entry
=
env
.
lookup
(
target
.
name
)
if
entry
.
is_type
and
entry
.
type
.
name
==
name
and
entry
.
type
.
module_name
==
self
.
module
.
module_name
.
value
:
continue
# already cimported
self
.
interned_items
.
append
(
(
env
.
intern_identifier
(
name
),
target
))
target
.
analyse_target_expression
(
env
,
None
)
if
target
.
type
is
py_object_type
:
coerced_item
=
None
else
:
coerced_item
=
self
.
item
.
coerce_to
(
target
.
type
,
env
)
self
.
interned_items
.
append
(
(
env
.
intern_identifier
(
name
),
target
,
coerced_item
))
#target.release_target_temp(env) # was release_temp ?!?
self
.
module
.
release_temp
(
env
)
self
.
item
.
release_temp
(
env
)
...
...
@@ -4630,7 +4634,7 @@ class FromImportStatNode(StatNode):
Naming
.
import_star
,
self
.
module
.
py_result
(),
code
.
error_goto
(
self
.
pos
)))
for
cname
,
target
in
self
.
interned_items
:
for
cname
,
target
,
coerced_item
in
self
.
interned_items
:
code
.
putln
(
'%s = PyObject_GetAttr(%s, %s); %s'
%
(
self
.
item
.
result
(),
...
...
@@ -4638,7 +4642,14 @@ class FromImportStatNode(StatNode):
cname
,
code
.
error_goto_if_null
(
self
.
item
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
item
.
py_result
())
target
.
generate_assignment_code
(
self
.
item
,
code
)
if
coerced_item
is
None
:
target
.
generate_assignment_code
(
self
.
item
,
code
)
else
:
coerced_item
.
allocate_temp_result
(
code
)
coerced_item
.
generate_result_code
(
code
)
target
.
generate_assignment_code
(
coerced_item
,
code
)
if
self
.
item
.
result
()
!=
coerced_item
.
result
():
code
.
put_decref_clear
(
self
.
item
.
result
(),
self
.
item
.
type
)
self
.
module
.
generate_disposal_code
(
code
)
self
.
module
.
free_temps
(
code
)
...
...
tests/run/importfrom.pyx
View file @
0a677a76
...
...
@@ -8,6 +8,11 @@ True
True
>>> import4() == (cmd, core, version)
True
>>> typed_imports()
True
True
an integer is required
Expected tuple, got int
"""
def
import1
():
...
...
@@ -37,3 +42,27 @@ def import3():
def
import4
():
from
distutils
import
cmd
,
core
,
version
return
cmd
,
core
,
version
def
typed_imports
():
import
sys
cdef
long
maxint
cdef
tuple
t
from
sys
import
maxint
print
maxint
==
sys
.
maxint
from
sys
import
version_info
as
t
print
t
is
sys
.
version_info
try
:
from
sys
import
version_info
as
maxint
except
TypeError
,
e
:
print
e
try
:
from
sys
import
maxint
as
t
except
TypeError
,
e
:
print
e
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