naimetti / rfc3339-validator

A pure python RFC3339 validator
MIT License
8 stars 11 forks source link

Fix test failure on darwin #3

Closed rmcgibbo closed 3 years ago

rmcgibbo commented 3 years ago

On darwin, the tests fail: https://nix-cache.s3.amazonaws.com/log/z095m9zik39gh3miqp3w03z8dxbynnqx-python3.9-rfc3339-validator-0.1.3.drv

The issue looks like this: https://bugs.python.org/issue13305

About Elena Oat's patch issue13305.diff: I'm not sure that strftime("%4Y") works on all platforms

It doesn't, that's what the patch is trying to document. AFAICT it works on my Linux (but not on yours), it gives '4Y' on Mac, and raises an error on Windows. This should depend on the libc used by system, so the same OS can give different results depending on which libc it uses, and the only sure thing is > that %4Y is not a portable solution. FWIW the patch LGTM (except a couple minor nits -- zero-pad should be hyphenated and there should be a double space after the dot), but I'm not sure if it's better mentioning platforms at all or just being vague and say that it works on some platforms but not others and leave up to the user figuring out where.

I worked around this by using %Y and restricting the tests to dates above 1000.

naimetti commented 3 years ago

Nice catch! Thanks!