Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Kirill Smelkov
cpython
Commits
5208e1da
Commit
5208e1da
authored
Aug 19, 1992
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unpack() now returns a tuple, not a list
parent
1b477403
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
Modules/structmodule.c
Modules/structmodule.c
+23
-1
No files found.
Modules/structmodule.c
View file @
5208e1da
...
@@ -317,6 +317,27 @@ struct_pack(self, args)
...
@@ -317,6 +317,27 @@ struct_pack(self, args)
}
}
/* Helper to convert a list to a tuple */
static
object
*
totuple
(
list
)
object
*
list
;
{
int
len
=
getlistsize
(
list
);
object
*
tuple
=
newtupleobject
(
len
);
if
(
tuple
!=
NULL
)
{
int
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
object
*
v
=
getlistitem
(
list
,
i
);
INCREF
(
v
);
settupleitem
(
tuple
,
i
,
v
);
}
}
DECREF
(
list
);
return
tuple
;
}
/* unpack(fmt, string) --> (v1, v2, ...) */
/* unpack(fmt, string) --> (v1, v2, ...) */
static
object
*
static
object
*
...
@@ -409,13 +430,14 @@ struct_unpack(self, args)
...
@@ -409,13 +430,14 @@ struct_unpack(self, args)
}
}
}
}
return
res
;
return
totuple
(
res
)
;
fail:
fail:
DECREF
(
res
);
DECREF
(
res
);
return
NULL
;
return
NULL
;
}
}
/* List of functions */
/* List of functions */
static
struct
methodlist
struct_methods
[]
=
{
static
struct
methodlist
struct_methods
[]
=
{
...
...
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