Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SMIRR Jean-Loup
igor
Commits
9c9a7bfc
Commit
9c9a7bfc
authored
Jul 21, 2012
by
W. Trevor King
Browse files
Python 3 scraps the iter(...).next() method, so use next(iter(...)).
parent
446da7b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
igor/struct.py
View file @
9c9a7bfc
...
...
@@ -252,11 +252,11 @@ class Field (object):
_LOG
.
debug
(
'unpack {} for {} {}'
.
format
(
data
,
self
,
self
.
format
))
iterator
=
iter
(
data
)
try
:
items
=
[
iterator
.
next
(
)
for
i
in
range
(
self
.
arg_count
)]
items
=
[
next
(
iterator
)
for
i
in
range
(
self
.
arg_count
)]
except
StopIteration
:
raise
ValueError
(
'not enough data to unpack {}'
.
format
(
self
))
try
:
iterator
.
next
(
)
next
(
iterator
)
except
StopIteration
:
pass
else
:
...
...
@@ -549,13 +549,13 @@ class Structure (_struct.Struct):
iterator
=
iter
(
args
)
for
f
in
self
.
fields
:
try
:
items
=
[
iterator
.
next
(
)
for
i
in
range
(
f
.
arg_count
)]
items
=
[
next
(
iterator
)
for
i
in
range
(
f
.
arg_count
)]
except
StopIteration
:
raise
ValueError
(
'not enough data to unpack {}.{}'
.
format
(
self
,
f
))
data
[
f
.
name
]
=
f
.
unpack_data
(
items
)
try
:
iterator
.
next
(
)
next
(
iterator
)
except
StopIteration
:
pass
else
:
...
...
@@ -671,7 +671,7 @@ class DynamicStructure (Structure):
... ],
... byte_order='>')
>>> b = '\x00\x00\x00\x02\x01\x02\x03\x04'
>>> b =
b
'\x00\x00\x00\x02\x01\x02\x03\x04'
>>> d = dynamic_length_vector.unpack(b)
>>> pprint(d)
{'data': array([258, 772]), 'length': 2}
...
...
Write
Preview
Supports
Markdown
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