Repository navigation
Conversation
str() on a float switches to exponent notation below 1e-04 and from 1e16 on, but FLOAT has no exponent in RFC 5545 3.3.7, so a GEO position near the equator was written as GEO:1e-05;-2e-05 and stricter parsers can reject it. Render both through to_ical_float(), which uses Decimal to write the shortest round-tripping decimal of the float in plain notation: 1e-05 becomes 0.00001 and 1e16 becomes 10000000000000000. Values that were already plain, such as 0.0 and 42.0, keep their current spelling. Closes PyCalendar#2136
|
Thanks for the pull request, @aplatogg! A maintainer will review it shortly. |
Mixed activityActivity patterns show a mix of organic and automated signals. Evidence
Last 5 PRs: This is an automated analysis by AgentScan |
|
One or more PR-quality checks did not pass. Review the PR Quality Checks summary in the workflow run for the failed checks and their details, then make any necessary updates. Checklist items may remain unchecked while work is in progress. Please tick each item as you complete it. If you used AI assistance, follow the project's Responsible AI use policy and provide the required disclosures. |
|
Closing this in favour of #2137. @fermsp opened that one at 02:38 for the same issue, mine at 07:0x, so a second PR here would only split review — the maintainer's comment is right. I reviewed #2137 against its own branch: \pytest src/icalendar/tests/test_issue_2136_float_exponent.py src/icalendar/tests/prop\ gives 1298 passed, 1 skipped, and the written values match the expected output of the issue (\ |
What this changes
vFloat.to_ical()andvGeo.to_ical()usedstr()on the float, which switches to exponent notation below1e-04and from1e16on. RFC 5545 3.3.7 has no exponent, so a GEO near the equator was written asGEO:1e-05;-2e-05and parsers that follow the grammar can reject it.Both now format through
to_ical_float(), which usesDecimalto render the shortest round-tripping decimal of the float in plain notation:Values that were already plain keep their spelling:
vFloat(0.0)is still0.0andvGeo((1.2, 3.0))is still1.2;3.0, so the existingtest_zeroandtest_prop_vGeoassertions hold.Tests
tests/prop/test_vFloat.py: exponent cases down to1e-7, an assertion that every written value matches the RFC grammar^[+-]?\d+(?:\.\d+)?$, and a write/read round trip.tests/prop/test_vGeo.py: the reported event, the GEO line, and a round trip.news/2136.bugfixfor the changelog.pytest src/icalendar/testsgives 15956 passed and 6 failed here; all 6 fail on unmodifiedmaintoo (hypothesisabsent, plus the two zoneinfo tests on Windows).ruff checkandruff format --checkpass for the touched files.Closes #2136
Prepared with an AI coding assistant (Claude), as the repository asks automated contributors to identify themselves.