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

Invalid date format - %Y\%m\%d #200

Open
FluffyDietEngine opened this issue Nov 17, 2023 · 0 comments
Open

Invalid date format - %Y\%m\%d #200

FluffyDietEngine opened this issue Nov 17, 2023 · 0 comments

Comments

@FluffyDietEngine
Copy link

Bug description - I am getting the below traceback when I tried to parse the following date from one of the documents I am working on. -> "2023\09\11"

Traceback

Traceback (most recent call last):
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 649, in parse
    ret = self._build_naive(res, default)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 1235, in _build_naive
    naive = default.replace(**repl)
            ^^^^^^^^^^^^^^^^^^^^^^^
ValueError: year 20239 is out of range

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/pendulum/parsing/__init__.py", line 131, in _parse
    dt = parser.parse(
         ^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 1368, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 651, in parse
    six.raise_from(ParserError(str(e) + ": %s", timestr), e)
  File "<string>", line 3, in raise_from
dateutil.parser._parser.ParserError: year 20239 is out of range: 20239

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/santhoshsolomon/Projects/async-scraper/prefect_module/test.py", line 5, in <module>
    parse(date_1)
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/maya/core.py", line 766, in parse
    dt = pendulum.parse(str(string), **options)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/pendulum/parser.py", line 29, in parse
    return _parse(text, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/pendulum/parser.py", line 45, in _parse
    parsed = base_parse(text, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/pendulum/parsing/__init__.py", line 74, in parse
    return _normalize(_parse(text, **_options), **_options)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/pendulum/parsing/__init__.py", line 135, in _parse
    raise ParserError("Invalid date string: {}".format(text))
pendulum.parsing.exceptions.ParserError: Invalid date string: 20239

While reading the traceback I have understood the issue is due to the escape string character \ and I have modified the date like "2023\09\11". Now the issue is something different, traceback as follows,

Traceback (most recent call last):
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/pendulum/parsing/__init__.py", line 131, in _parse
    dt = parser.parse(
         ^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 1368, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 643, in parse
    raise ParserError("Unknown string format: %s", timestr)
dateutil.parser._parser.ParserError: Unknown string format: 2023\09\11

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/santhoshsolomon/Projects/async-scraper/prefect_module/test.py", line 5, in <module>
    parse(date_1)
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/maya/core.py", line 766, in parse
    dt = pendulum.parse(str(string), **options)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/pendulum/parser.py", line 29, in parse
    return _parse(text, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/pendulum/parser.py", line 45, in _parse
    parsed = base_parse(text, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/pendulum/parsing/__init__.py", line 74, in parse
    return _normalize(_parse(text, **_options), **_options)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/santhoshsolomon/Projects/mr_hulk/venv/lib/python3.11/site-packages/pendulum/parsing/__init__.py", line 135, in _parse
    raise ParserError("Invalid date string: {}".format(text))
pendulum.parsing.exceptions.ParserError: Invalid date string: 2023\09\11

I am interested in knowing what is going wrong here.

Environment and Version

  • OS - Mac Sonama 14.0, ZSH terminal
  • Python Version: Python 3.11.5
  • maya Version: 0.6.1
  • Your timezone: IST
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

1 participant