Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Output pdf dicts in deterministic order #6427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Output pdf dictionaries in deterministic order
for #6317
  • Loading branch information
jkseppan committed May 15, 2016
commit e76e6071c99b0c8e2697a6f69b9d08014041222c
4 changes: 2 additions & 2 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def pdfRepr(obj):
# represented as Name objects.
elif isinstance(obj, dict):
r = [b"<<"]
r.extend([Name(key).pdfRepr() + b" " + pdfRepr(val)
for key, val in six.iteritems(obj)])
r.extend([Name(key).pdfRepr() + b" " + pdfRepr(obj[key])
for key in sorted(six.iterkeys(obj))])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The iterkeys seems unnecessary if you're going to sort it anyway; sorted(obj) should work just fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes sense.

r.append(b">>")
return fill(r)

Expand Down