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
60c762b7
Commit
60c762b7
authored
Jul 03, 2010
by
Alexander Belopolsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #9094: Make python -m pickletools disassemble pickles given in
the command line.
parent
df022da3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletion
+44
-1
Lib/pickletools.py
Lib/pickletools.py
+40
-1
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/pickletools.py
View file @
60c762b7
...
...
@@ -2330,4 +2330,43 @@ def _test():
return
doctest
.
testmod
()
if
__name__
==
"__main__"
:
_test
()
import
sys
,
argparse
parser
=
argparse
.
ArgumentParser
(
description
=
'disassemble one or more pickle files'
)
parser
.
add_argument
(
'pickle_file'
,
type
=
argparse
.
FileType
(
'br'
),
nargs
=
'*'
,
help
=
'the pickle file'
)
parser
.
add_argument
(
'-o'
,
'--output'
,
default
=
sys
.
stdout
,
type
=
argparse
.
FileType
(
'w'
),
help
=
'the file where the output should be written'
)
parser
.
add_argument
(
'-m'
,
'--memo'
,
action
=
'store_true'
,
help
=
'preserve memo between disassemblies'
)
parser
.
add_argument
(
'-l'
,
'--indentlevel'
,
default
=
4
,
type
=
int
,
help
=
'the number of blanks by which to indent a new MARK level'
)
parser
.
add_argument
(
'-p'
,
'--preamble'
,
default
=
"==> {name} <=="
,
help
=
'if more than one pickle file is specified, print this before'
' each disassembly'
)
parser
.
add_argument
(
'-t'
,
'--test'
,
action
=
'store_true'
,
help
=
'run self-test suite'
)
parser
.
add_argument
(
'-v'
,
action
=
'store_true'
,
help
=
'run verbosely; only affects self-test run'
)
args
=
parser
.
parse_args
()
if
args
.
test
:
_test
()
else
:
if
not
args
.
pickle_file
:
parser
.
print_help
()
elif
len
(
args
.
pickle_file
)
==
1
:
dis
(
args
.
pickle_file
[
0
],
args
.
output
,
indentlevel
=
args
.
indentlevel
)
else
:
memo
=
{}
if
args
.
memo
else
None
for
f
in
args
.
pickle_file
:
preamble
=
args
.
preamble
.
format
(
name
=
f
.
name
)
args
.
output
.
write
(
preamble
+
'
\
n
'
)
dis
(
f
,
args
.
output
,
memo
,
args
.
indentlevel
)
Misc/NEWS
View file @
60c762b7
...
...
@@ -468,6 +468,10 @@ C-API
Library
-------
- Issue #9094: python -m pickletools will now disassemble pickle files
listed in the command line arguments. See output of python -m
pickletools -h for more details.
- Issue #5468: urlencode to handle bytes type and other encodings in its query
parameter. Patch by Dan Mahn.
...
...
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