cerebras_dev_50_samples / output.jsonl
aarticerebras's picture
Upload output.jsonl
e79d94c verified
{"repo": "marshmallow-code/marshmallow","instance_id": "marshmallow-code__marshmallow-1252","base_commit": "b063a103ae5222a5953cd7453a1eb0d161dc5b52","patch": "diff --git a/src/marshmallow/utils.py b/src/marshmallow/utils.py\n--- a/src/marshmallow/utils.py\n+++ b/src/marshmallow/utils.py\n@@ -285,6 +285,9 @@ def from_iso(datestring, use_dateutil=True):\n # Strip off timezone info.\n if '.' in datestring:\n # datestring contains microseconds\n+ (dt_nomstz, mstz) = datestring.split('.')\n+ ms_notz = mstz[:len(mstz) - len(mstz.lstrip('0123456789'))]\n+ datestring = '.'.join((dt_nomstz, ms_notz))\n return datetime.datetime.strptime(datestring[:26], '%Y-%m-%dT%H:%M:%S.%f')\n return datetime.datetime.strptime(datestring[:19], '%Y-%m-%dT%H:%M:%S')\n \n","test_patch": "diff --git a/tests/test_utils.py b/tests/test_utils.py\n--- a/tests/test_utils.py\n+++ b/tests/test_utils.py\n@@ -200,6 +200,15 @@ def test_from_iso_datetime(use_dateutil, timezone):\n assert type(result) == dt.datetime\n assert_datetime_equal(result, d)\n \n+ # Test with 3-digit only microseconds\n+ #\u00a0Regression test for https://github.com/marshmallow-code/marshmallow/issues/1251\n+ d = dt.datetime.now(tz=timezone).replace(microsecond=123000)\n+ formatted = d.isoformat()\n+ formatted = formatted[:23] + formatted[26:]\n+ result = utils.from_iso(formatted, use_dateutil=use_dateutil)\n+ assert type(result) == dt.datetime\n+ assert_datetime_equal(result, d)\n+\n def test_from_iso_with_tz():\n d = central.localize(dt.datetime.now())\n formatted = d.isoformat()\n","problem_statement": "ISO8601 DateTimes ending with Z considered not valid in 2.19.4\nProbably related to #1247 and #1234 - in marshmallow `2.19.4`, with `python-dateutil` _not_ installed, it seems that loading a datetime in ISO8601 that ends in `Z` (UTC time) results in an error:\r\n\r\n```python\r\nclass Foo(Schema):\r\n date = DateTime(required=True)\r\n\r\n\r\nfoo_schema = Foo(strict=True)\r\n\r\na_date_with_z = '2019-06-17T00:57:41.000Z'\r\nfoo_schema.load({'date': a_date_with_z})\r\n```\r\n\r\n```\r\nmarshmallow.exceptions.ValidationError: {'date': ['Not a valid datetime.']}\r\n```\r\n\r\nDigging a bit deeper, it seems [`from_iso_datetime`](https://github.com/marshmallow-code/marshmallow/blob/dev/src/marshmallow/utils.py#L213-L215) is failing with a `unconverted data remains: Z` - my understanding of the spec is rather limited, but it seems that they are indeed valid ISO8601 dates (and in `marshmallow==2.19.3` and earlier, the previous snippet seems to work without raising validation errors).\r\n\n","hints_text": "@lafrech Would you mind looking into this?\nThanks for reporting.\r\n\r\nThis is definitely a side effect of https://github.com/marshmallow-code/marshmallow/pull/1249/files. Sorry about that.\r\n\r\nI don't own a copy of the spec, so the work on this is based on examples... I assumed that microseconds always came as a six-pack. It seems only three digits (your example) is acceptable. From what I understand in the regex we copied from Django, we could even expect any number of digits in [1; 6].\r\n\r\nI see two solutions to this:\r\n\r\n- Split around `\".\"`, then in the right part, get all numbers and ignore letters/symbols.\r\n- Split around `\".\"`, then split the right part around anything that delimitates a timezone (`\"Z\"`, `\"+\"`, `\"-\"`, what else?).\r\n\r\n\nThanks both for the prompt reply! I don't have a copy of the spec myself either - for the timezone suffix, I have based my previous comment on [the Wikipedia entry](https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators), which seems to hint at the following designators being allowed:\r\n```\r\n<time>Z\r\n<time>\u00b1hh:mm\r\n<time>\u00b1hhmm\r\n<time>\u00b1hh\r\n```\nI also use this WP page, but it doesn't show much about milli/microseconds.","created_at": "2019-06-17T13:44:50Z","version": "2.19","FAIL_TO_PASS": "[\"tests/test_utils.py::test_from_iso_datetime[timezone1-False]\"]","PASS_TO_PASS": "[\"tests/test_utils.py::test_missing_singleton_copy\", \"tests/test_utils.py::test_to_marshallable_type\", \"tests/test_utils.py::test_to_marshallable_type_none\", \"tests/test_utils.py::test_to_marshallable_type_with_namedtuple\", \"tests/test_utils.py::test_get_value_from_object[obj0]\", \"tests/test_utils.py::test_get_value_from_object[obj1]\", \"tests/test_utils.py::test_get_value_from_object[obj2]\", \"tests/test_utils.py::test_get_value_from_namedtuple_with_default\", \"tests/test_utils.py::test_get_value_for_nested_object\", \"tests/test_utils.py::test_get_value_from_dict\", \"tests/test_utils.py::test_get_value\", \"tests/test_utils.py::test_set_value\", \"tests/test_utils.py::test_is_keyed_tuple\", \"tests/test_utils.py::test_to_marshallable_type_list\", \"tests/test_utils.py::test_to_marshallable_type_generator\", \"tests/test_utils.py::test_marshallable\", \"tests/test_utils.py::test_is_collection\", \"tests/test_utils.py::test_rfcformat_gmt_naive\", \"tests/test_utils.py::test_rfcformat_central\", \"tests/test_utils.py::test_rfcformat_central_localized\", \"tests/test_utils.py::test_isoformat\", \"tests/test_utils.py::test_isoformat_tzaware\", \"tests/test_utils.py::test_isoformat_localtime\", \"tests/test_utils.py::test_from_datestring\", \"tests/test_utils.py::test_from_rfc[True]\", \"tests/test_utils.py::test_from_rfc[False]\", \"tests/test_utils.py::test_from_iso_datetime[None-True]\", \"tests/test_utils.py::test_from_iso_datetime[None-False]\", \"tests/test_utils.py::test_from_iso_datetime[timezone1-True]\", \"tests/test_utils.py::test_from_iso_with_tz\", \"tests/test_utils.py::test_from_iso_time_with_microseconds[True]\", \"tests/test_utils.py::test_from_iso_time_with_microseconds[False]\", \"tests/test_utils.py::test_from_iso_time_without_microseconds[True]\", \"tests/test_utils.py::test_from_iso_time_without_microseconds[False]\", \"tests/test_utils.py::test_from_iso_date[True]\", \"tests/test_utils.py::test_from_iso_date[False]\", \"tests/test_utils.py::test_get_func_args\"]","environment_setup_commit": "dd72a797ceeea63ee04d5e1838c3a5a1432347e3"}