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

fix borrow error when serializing recursive models #764

Merged
merged 1 commit into from
Jul 11, 2023
Merged

Conversation

davidhewitt
Copy link
Contributor

@davidhewitt davidhewitt commented Jul 11, 2023

Change Summary

Fixes a borrow error when serializing a recursive model.

The cause was because we took a &mut borrow on the SchemaSerializer in to_json but then attempt to clone (!!) it when we fetch __pydantic_serializer__.

I've changed to (a) not take a &mut borrow and (b) not clone when fetching __pydantic_serializer__.

Related issue number

pydantic/pydantic#6571

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @samuelcolvin

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 11, 2023

CodSpeed Performance Report

Merging #764 will not alter performance

Comparing dh/pyd-issue-6571 (f136db9) with main (3e7cc4f)

Summary

✅ 126 untouched benchmarks

@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Merging #764 (f136db9) into main (3e7cc4f) will decrease coverage by 0.03%.
The diff coverage is 88.88%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #764      +/-   ##
==========================================
- Coverage   93.65%   93.63%   -0.03%     
==========================================
  Files          99       99              
  Lines       14148    14149       +1     
  Branches       25       25              
==========================================
- Hits        13250    13248       -2     
- Misses        892      895       +3     
  Partials        6        6              
Impacted Files Coverage Δ
src/serializers/mod.rs 98.55% <80.00%> (-0.48%) ⬇️
src/serializers/infer.rs 96.89% <100.00%> (ø)
src/serializers/shared.rs 90.06% <100.00%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e7cc4f...f136db9. Read the comment docs.

@davidhewitt
Copy link
Contributor Author

please review

@adriangb adriangb merged commit 5f660f0 into main Jul 11, 2023
28 checks passed
@adriangb adriangb deleted the dh/pyd-issue-6571 branch July 11, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants