FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Nicer error when packing a datetime without tzinfo by begelundmuller · Pull Request #466 · msgpack/msgpack-python · GitHub

Nicer error when packing a datetime without tzinfo - #466

Merged
methane merged 3 commits into
msgpack:mainfrom
begelundmuller:main
Nov 16, 2021
Merged

Nicer error when packing a datetime without tzinfo#466
methane merged 3 commits into
msgpack:mainfrom
begelundmuller:main

Conversation

Copy link
Copy Markdown
Contributor

When attempting to pack a datetime.datetime object with msgpack.packb(dt, datetime=True) where the dt object is missing tzinfo, the library throws the generic error TypeError: can not serialize 'datetime.datetime' object.

That threw me off as I thought the problem related to datetime=True, and didn't realise I was missing tzinfo. This small patch outputs a more specific error message for that edge case.

codecov-io commented Feb 26, 2021
edited
Loading

Copy link
Copy Markdown

Codecov Report

Merging #466 (d845b65) into main (4ace82f) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #466      +/-   ##
==========================================
+ Coverage   87.80%   87.84%   +0.03%     
==========================================
  Files           5        5              
  Lines         730      732       +2     
==========================================
+ Hits          641      643       +2     
  Misses         89       89              
Impacted Files Coverage Δ
msgpack/fallback.py 88.85% <100.00%> (+0.03%) ⬆️

Continue to review full report at Codecov.

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

Comment thread msgpack/_packer.pyx Outdated

Copy link
Copy Markdown
Contributor Author

Addressed your comment in this new commit – it now respects the default function.

The logic is getting a little twisted, though. If you don't think it's worth it for such a minor convenience, I understand.

methane merged commit e464cb4 into msgpack:main Nov 16, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL