Skip to content
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

Several functions have mutable default arguments #355

Closed
rileyjmurray opened this issue Oct 16, 2023 · 1 comment
Closed

Several functions have mutable default arguments #355

rileyjmurray opened this issue Oct 16, 2023 · 1 comment
Labels
bug A bug or regression

Comments

@rileyjmurray
Copy link
Contributor

rileyjmurray commented Oct 16, 2023

I came across a function in pygsti version 0.9.11.2 that has a mutable default argument. This can lead to nasty bugs, as described here. Once I found the first bug of this kind, I ran some searches and found several more. See below for a list.

Search results

I ran a regex search for strings of the form =[]<characters here>): [1] and found the following hits:
image

If I search for strings of the form ={}<characters here>): [2], I get
image

Footnotes

[Footnote 1] <insert characters here> is a placeholder for any character sequence that excludes new lines. The actual regex I used was =\[\].+\):. Note that this doesn't capture all possible cases where we have mutable default arguments, since it will miss cases of multi-line function definitions where the mutable argument isn't on the last line.

[Footnote 2] The actual regex I used was =\{\}.+\):.

You can search for both patterns I checked with =[\{\[][\}\]].+\):.

@rileyjmurray rileyjmurray added the bug A bug or regression label Oct 16, 2023
@sserita sserita added the fixed but not in release yet Bug has been fixed, but isn't in an official release yet (just exists on a development branch) label Nov 17, 2023
@sserita
Copy link
Contributor

sserita commented Nov 29, 2023

Closed with release of 0.9.12.

@sserita sserita closed this as completed Nov 29, 2023
@sserita sserita removed the fixed but not in release yet Bug has been fixed, but isn't in an official release yet (just exists on a development branch) label Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug or regression
Projects
None yet
Development

No branches or pull requests

2 participants