Allow colon in a plain scalar in a flow context#45
Conversation
|
Hey @dbeer1! Refresh my memory, is this valid for scalars even in 1.1 or just 1.2? At the moment, pyyaml and libyaml only support 1.1. |
tests/data/spec-08-13.canonical
Outdated
| --- | ||
| !!map { | ||
| ? !!str "foo" | ||
| ? !!str "foo :" |
There was a problem hiding this comment.
Did this fail prior to this change?
There was a problem hiding this comment.
It passed, but the key was parsed as "foo". Note that pyyaml and libyaml behave differently in this edge case, libyaml rejects any colon in a flow context without a space afterwards, while pyyaml allows ',[]{}' after a colon as well.
Compare https://github.com/yaml/pyyaml/blob/master/lib/yaml/scanner.py#L1301 vs https://github.com/yaml/libyaml/blob/master/src/scanner.c#L3438
There was a problem hiding this comment.
I reverted this test and behavior with regard to empty values in flow mappings in the latest commit, fyi.
|
I just check in the specs, and it appears to be the same for 1.1 and 1.2. From 1.1:
So Related issue: adrienverge/yamllint#30 |
|
Hi @sigmavirus24, do you have any update on this? |
|
Kirill strayed from the spec a few times when he thought it was really not the right thing to do. I suspect this might be the case. I just tested this using the new YAML Editor: http://pasteboard.co/vYxs4oX8D.png Seems like most frameworks accept it, except the libyaml ones. Since it is in the spec and EveryonesDoingIt™, I move to add this to libyaml and all its bindings. |
|
Thanks for confirming that detail @ingydotnet |
|
Thanks! Note that the C binding pull request (yaml/libyaml#28) needs to be updated to follow the modified logic here with regard to a missing value after a colon, eg |
|
@sigmavirus24 Can a new release be drafted with this change? I'm waiting for it so my I can update my docker containers without moving from the simple |
|
@sigmavirus24 Would it be possible to make a new release with these changes? Thank you! |
|
Hi all, I see that the change was already merged.
We have a similar request in SnakeYAML |
|
The same change is implemented in SnakeYAML: https://bitbucket.org/asomov/snakeyaml/issues/397 |
|
@asomov The PyYAML release of this is being planned to happen in the next 48 hours. Would you mind dropping by #pyyaml on irc.freenode.net to discuss? |
|
Commit c5b135f causes a syntax error on Python 3.2.3. Yes I know, 3.2.3 is over 9 years old, but I wanted to at least note this "regression" of sort somewhere in case others come across it. I have not tested Python 2.x. |
Commit c268a82 "key-duplicates: Don't crash on redundant closing brackets or braces" fixed a problem but introduced another one: it crashes on systems with (I guess) an old version of PyYAML. This is probably linked to the "Allow colon in a plain scalar in a flow context" issue on PyYAML [1]. For example, this problem happens on CentOS 8: FAIL: test_disabled (tests.rules.test_key_duplicates.KeyDuplicatesTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "…/tests/rules/test_key_duplicates.py", line 90, in test_disabled '{a:1, b:2}}\n', conf, problem=(2, 11, 'syntax')) File "…/tests/common.py", line 54, in check self.assertEqual(real_problems, expected_problems) AssertionError: Lists differ: … - [2:3: syntax error: found unexpected ':' (syntax)] + [2:11: <no description>] I propose to simply fix the *space following a colon* problem, since it's not related to what the original author @tamere-allo-peter tried to fix. [1]: yaml/pyyaml#45
Commit c268a82 "key-duplicates: Don't crash on redundant closing brackets or braces" fixed a problem but introduced another one: it crashes on systems with (I guess) an old version of PyYAML. This is probably linked to the "Allow colon in a plain scalar in a flow context" issue on PyYAML [1]. For example, this problem happens on CentOS 8: FAIL: test_disabled (tests.rules.test_key_duplicates.KeyDuplicatesTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "…/tests/rules/test_key_duplicates.py", line 90, in test_disabled '{a:1, b:2}}\n', conf, problem=(2, 11, 'syntax')) File "…/tests/common.py", line 54, in check self.assertEqual(real_problems, expected_problems) AssertionError: Lists differ: … - [2:3: syntax error: found unexpected ':' (syntax)] + [2:11: <no description>] I propose to simply fix the *space following a colon* problem, since it's not related to what the original author @tamere-allo-peter tried to fix. [1]: yaml/pyyaml#45
Quote scalars with colons in flow style collection SUMMARY Older versions of libyaml and pyyaml don't support colons in scalars that appear in flow style collections. This adds quotes to the handful of cases where they are used in the integration tests. This was uncovered by downstream testing. I am only able to reproduce the problem on the supported ee-minimal-rhel8 image. I believe this is because even though pyyaml should be recent enough, it has likely been compiled against an older version of libyaml that does not have the fix. See: yaml/libyaml#104 yaml/pyyaml#45 It's worth noting that running ansible-lint --fix will undo these changes, which is how I think they were made in the first place. ISSUE TYPE Bugfix Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Bikouo Aubin Reviewed-by: GomathiselviS
Quote scalars with colons in flow style collection SUMMARY Older versions of libyaml and pyyaml don't support colons in scalars that appear in flow style collections. This adds quotes to the handful of cases where they are used in the integration tests. This was uncovered by downstream testing. I am only able to reproduce the problem on the supported ee-minimal-rhel8 image. I believe this is because even though pyyaml should be recent enough, it has likely been compiled against an older version of libyaml that does not have the fix. See: yaml/libyaml#104 yaml/pyyaml#45 It's worth noting that running ansible-lint --fix will undo these changes, which is how I think they were made in the first place. ISSUE TYPE Bugfix Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Bikouo Aubin Reviewed-by: GomathiselviS (cherry picked from commit 68fb0a3)
[PR #2014/68fb0a31 backport][stable-7] Quote scalars with colons in flow style collection This is a backport of PR #2014 as merged into main (68fb0a3). SUMMARY Older versions of libyaml and pyyaml don't support colons in scalars that appear in flow style collections. This adds quotes to the handful of cases where they are used in the integration tests. This was uncovered by downstream testing. I am only able to reproduce the problem on the supported ee-minimal-rhel8 image. I believe this is because even though pyyaml should be recent enough, it has likely been compiled against an older version of libyaml that does not have the fix. See: yaml/libyaml#104 yaml/pyyaml#45 It's worth noting that running ansible-lint --fix will undo these changes, which is how I think they were made in the first place. ISSUE TYPE Bugfix Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Mark Chappell
This pull is analogous to yaml/libyaml#28. It changes the behavior of pyyaml the same way the other pull changes the behavior of libyaml.