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

strconv.convert('') returns a datetime of today's date #5

Open
armike opened this issue Dec 8, 2015 · 3 comments
Open

strconv.convert('') returns a datetime of today's date #5

armike opened this issue Dec 8, 2015 · 3 comments

Comments

@armike
Copy link

armike commented Dec 8, 2015

I expected either None or '', but a datetime was completely unanticipated. A converter for None-like inputs might do the trick, or '' could be treated as a string.

@chid
Copy link
Contributor

chid commented Feb 22, 2016

It's due to behavior in the from dateutil.parser import parse section.

I think that best place to change it this line https://github.com/bruth/strconv/blob/master/strconv.py#L117

@chid
Copy link
Contributor

chid commented Feb 22, 2016

two solutions, either use a different module, like from dateparser import parse as duparse or use something like this, if isinstance(s, str) and s.strip() != '': in line 117

@benmaier
Copy link

In version 0.4.2 (installed from this repo, not PyPI, see #12):

In [15]: strconv.convert('')
Out[15]: ''

In [16]: strconv.infer('') is None
Out[16]: True

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