GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: save empty IAM policy bindings by busunkim96 · Pull Request #155 · googleapis/python-api-core

This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Conversation

@busunkim96

@busunkim96 busunkim96 commented Mar 22, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #154

__getitem__ currently returns an empty set() for items not in the bindings. If someone adds to the set returned by __getitem__ the changes will not be reflected on the actual policy object.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@busunkim96
fix: sae empty IAM bindings
762e443
@busunkim96
busunkim96 requested a review from a team March 22, 2021 21:52
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 22, 2021
busunkim96
busunkim96 commented Mar 22, 2021
View reviewed changes
Comment thread tests/unit/test_iam.py
Comment on lines +35 to +36
assert len(policy) == 0
assert dict(policy) == {}

@busunkim96 busunkim96 Mar 22, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Accessing policy.owners, policy.editors results in __getitem__ being called, which adds empty entries to the dictionary. I moved these empty dict asserts up as a result.

An alternative is to keep them in their previous location and check that the three roles with empty bindings were added

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@busunkim96
busunkim96 requested review from frankyn and parthea March 22, 2021 21:56
@busunkim96
chore: remove empty line
a6a0c9c
parthea
parthea approved these changes Mar 23, 2021
View reviewed changes
@busunkim96
busunkim96 merged commit 536c2ca into master Mar 23, 2021
@busunkim96
busunkim96 deleted the fix-154 branch March 23, 2021 19:16
@busunkim96 busunkim96 mentioned this pull request Mar 24, 2021
fix: skip empty policy bindings in len() and iter() #159
Merged
gcf-merge-on-green Bot pushed a commit that referenced this pull request Mar 25, 2021
@busunkim96
fix: skip empty policy bindings in len() and iter() (#159)
9eaa786
Exclude empty policy bindings (bindings with no members) in
`Policy.__iter__()` and `Policy.__len__()`

Follow up to #155
This was referenced May 30, 2025
chore(main): release 2.0.0 #822
Closed
chore(main): release 2.0.0 #823
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@frankyn frankyn Awaiting requested review from frankyn
1 more reviewer
@parthea parthea parthea approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

google.api_core.iam.Policy.__getitem__ does not correctly save empty bindings

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@busunkim96 @parthea
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.