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

parse('February 21, 1994') fails for 2.0.0 #205

Closed
timofurrer opened this issue May 10, 2018 · 6 comments
Closed

parse('February 21, 1994') fails for 2.0.0 #205

timofurrer opened this issue May 10, 2018 · 6 comments

Comments

@timofurrer
Copy link

We at maya have some test doing things like:

pendulum.parse('February 21, 1994')

This works fine for releases prior to 2.0.0 but fails for 2.0.0 with the following traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tuxtimo/work/maya/env/lib/python3.6/site-packages/pendulum/parser.py", line 20, in parse
    return _parse(text, **options)
  File "/home/tuxtimo/work/maya/env/lib/python3.6/site-packages/pendulum/parser.py", line 36, in _parse
    parsed = base_parse(text, **options)
  File "/home/tuxtimo/work/maya/env/lib/python3.6/site-packages/pendulum/parsing/__init__.py", line 64, in parse
    return _normalize(_parse(text, **_options), **_options)
  File "/home/tuxtimo/work/maya/env/lib/python3.6/site-packages/pendulum/parsing/__init__.py", line 116, in _parse
    raise ParserError('Unable to parse string [{}]'.format(text))
pendulum.parsing.exceptions.ParserError: Unable to parse string [February 21, 1994]

What's going on here? Is this format not supported any more?

timofurrer added a commit to kennethreitz/maya that referenced this issue May 10, 2018
@sdispater
Copy link
Owner

@timofurrer The API has changed slightly in the new 2.0 release. The parser is now strict by default (i.e. it only parses ISO 8601 strings and some common ones). If you want to retrieve the previous behavior you have to pass strict=False to parse()

@ViktorHaag
Copy link

ViktorHaag commented May 10, 2018

@timofurrer I've also determined that, from maya's point of view, the parser now returns things that are not just datetimes (also intervals, durations?), and there seems a pervasive assumption inside maya that pendulum's parser returns only datetimes. (This might not be considered a functional change in the pendulum parser API, I guess, but it doesn't seem to have been considered as possible in maya...)

@timofurrer
Copy link
Author

@sdispater Alright, thanks for the hint. I'll try that

@ViktorHaag That's definitely something we need to have a look at. But how is that not a functional change in the pandulum parser API? Seems like one :)

@ViktorHaag
Copy link

ViktorHaag commented May 10, 2018

@timofurrer I don't know if it was ever promised that pendulum.parse was a public API, or that it would always return something you could treat like a datetime, or whether you inferred that based on its availability and behaviour... but in any case, the switch in version from 1.5.x to 2.x pretty clearly indicates that this might be a not-backwards-compatible boundary, so ...

I don't want to start up a dispute here about "what's a major change and what isn't" or "what's an API and what isn't"... I was just trying to point out that there was more than just strict parsing that would cause issues with Maya's use of this library.

@timofurrer
Copy link
Author

Okay, that's fine. I wasn't aware that it's not a public API :)
We definitely have to check how the functionalities we use, behave in pendulum 2.x and see how we can integrate those.

In any case, thanks for the hint. 🍻

@timofurrer
Copy link
Author

I'm going to close this for now.

Thanks guys 🍻

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

No branches or pull requests

3 participants