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

yaml.load(s, Loader=...) requires Loader= argument always #561

Merged
merged 4 commits into from
Sep 23, 2021

Conversation

ingydotnet
Copy link
Member

No description provided.

@ingydotnet ingydotnet changed the base branch from master to release/6.0 September 22, 2021 22:59
Copy link
Member

@perlpunk perlpunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would make sense to keep the warning for another while.
Note that yaml.add_constructor (and other methods) will add given constructors to Loader, FullLoader and UnsafeLoader, so people will be wondering why none of their custom constructors have an effect.
It should be recommended to only use add_constructor for a specific loader, and ideally to their own loader inheriting from one of the existing loaders.
While (hopefully) most users by now are using a specific loader for loading, there is still code out there that just disables the warning, and will stop working if they used custom constructors via yaml.add_constructor.
If something stops working and they enable warnings to investigate, they should be able to see a helpful message saying that the default loader has now been changed.

@ingydotnet
Copy link
Member Author

Maybe it would make sense to keep the warning for another while.

I'll add a warning if Full or Unsafe loaders had constructors added and load() is called without an explicit Loader=

@ingydotnet ingydotnet changed the title yaml.load(s) defaults to yaml.load(s, Loader=yaml.SafeLoader) yaml.load(s, Loader=...) requires Loader= argument always Sep 23, 2021
@ingydotnet
Copy link
Member Author

This started as load() defaults to Loader=SafeLoader but we all decided it was better to require Loader=... arg for load().

Copy link
Member

@perlpunk perlpunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test for the missing argument case?

tests/lib/test_dump_load.py Show resolved Hide resolved
@@ -1,5 +1,5 @@

.PHONY: default build buildext force forceext install installext test testext dist clean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this unintended stuff for this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@ingydotnet
Copy link
Member Author

Is there a test for the missing argument case?

Done in 1b2f534

@ingydotnet ingydotnet merged commit 1b2f534 into release/6.0 Sep 23, 2021
@ingydotnet ingydotnet deleted the load-default-safe branch September 23, 2021 21:40
stuhood pushed a commit to pantsbuild/pants that referenced this pull request Oct 20, 2021
PyYAML 6:
```
6.0 (2021-10-13)

* yaml/pyyaml#327 -- Change README format to Markdown
* yaml/pyyaml#483 -- Add a test for YAML 1.1 types
* yaml/pyyaml#497 -- fix float resolver to ignore `.` and `._`
* yaml/pyyaml#550 -- drop Python 2.7
* yaml/pyyaml#553 -- Fix spelling of “hexadecimal”
* yaml/pyyaml#556 -- fix representation of Enum subclasses
* yaml/pyyaml#557 -- fix libyaml extension compiler warnings
* yaml/pyyaml#560 -- fix ResourceWarning on leaked file descriptors
* yaml/pyyaml#561 -- always require `Loader` arg to `yaml.load()`
* yaml/pyyaml#564 -- remove remaining direct distutils usage
```
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Oct 23, 2021
Now uses "vendored" distutils from setuptools by default
rather than from Python stdlib.

Changes
=======

* yaml/pyyaml#327
  -- Change README format to Markdown
* yaml/pyyaml#483
  -- Add a test for YAML 1.1 types
* yaml/pyyaml#497
  -- fix float resolver to ignore `.` and `._`
* yaml/pyyaml#550
  -- drop Python 2.7
* yaml/pyyaml#553
  -- Fix spelling of “hexadecimal”
* yaml/pyyaml#556
  -- fix representation of Enum subclasses
* yaml/pyyaml#557
  -- fix libyaml extension compiler warnings
* yaml/pyyaml#560
  -- fix ResourceWarning on leaked file descriptors
* yaml/pyyaml#561
  -- always require `Loader` arg to `yaml.load()`
* yaml/pyyaml#564
  -- remove remaining direct distutils usage

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
woodsts pushed a commit to woodsts/buildroot that referenced this pull request Feb 21, 2022
… pyaml 6.0

Fixes https://gitlab.com/buildroot.org/buildroot/-/jobs/2088684091

python sample_python_pyyaml_dec.py
Traceback (most recent call last):
  File "/root/sample_python_pyyaml_dec.py", line 5, in <module>
    data = yaml.load(serialized)
TypeError: load() missing 1 required positional argument: 'Loader'

yaml.load() requires a loader argument since the move to version 6.0:
yaml/pyyaml#561

The test does not need the extra functionality of load(), so instead move to
the recommended safe_load().

Signed-off-by: Peter Korsgaard <[email protected]>
Tested-by: Romain Naour <[email protected]>
Signed-off-by: Peter Korsgaard <[email protected]>
gnuoy pushed a commit to gnuoy/zaza-openstack-tests that referenced this pull request Mar 25, 2022
Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650
gnuoy pushed a commit to gnuoy/zaza-openstack-tests that referenced this pull request Mar 25, 2022
Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650
gnuoy pushed a commit to gnuoy/zaza-openstack-tests that referenced this pull request Mar 25, 2022
Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650
gnuoy pushed a commit to gnuoy/zaza-openstack-tests that referenced this pull request Mar 25, 2022
Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650
gnuoy pushed a commit to gnuoy/zaza-openstack-tests that referenced this pull request Mar 25, 2022
Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650
gnuoy pushed a commit to gnuoy/zaza-openstack-tests that referenced this pull request Mar 25, 2022
Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650
gnuoy pushed a commit to gnuoy/zaza-openstack-tests that referenced this pull request Mar 25, 2022
Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650
gnuoy pushed a commit to gnuoy/zaza-openstack-tests that referenced this pull request Mar 25, 2022
Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650
ajkavanagh pushed a commit to openstack-charmers/zaza-openstack-tests that referenced this pull request Mar 25, 2022
* Use yaml.safe_load()

Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650

* Use snapshot_support=True for manila share type

The extra specs of a manila share type need to match the
share service's capabilities. [1]

[1] https://docs.openstack.org/manila/pike/admin/shared-file-systems-troubleshoot.html#id2

Closes-Bug: #1962204

Co-authored-by: Felipe Reyes <[email protected]>
Co-authored-by: Corey Bryant <[email protected]>
ajkavanagh pushed a commit to openstack-charmers/zaza-openstack-tests that referenced this pull request Mar 25, 2022
* Use yaml.safe_load()

Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650

* Use snapshot_support=True for manila share type

The extra specs of a manila share type need to match the
share service's capabilities. [1]

[1] https://docs.openstack.org/manila/pike/admin/shared-file-systems-troubleshoot.html#id2

Closes-Bug: #1962204

Co-authored-by: Felipe Reyes <[email protected]>
Co-authored-by: Corey Bryant <[email protected]>
ajkavanagh pushed a commit to openstack-charmers/zaza-openstack-tests that referenced this pull request Mar 25, 2022
* Use yaml.safe_load()

Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650

* Use snapshot_support=True for manila share type

The extra specs of a manila share type need to match the
share service's capabilities. [1]

[1] https://docs.openstack.org/manila/pike/admin/shared-file-systems-troubleshoot.html#id2

Closes-Bug: #1962204

Co-authored-by: Felipe Reyes <[email protected]>
Co-authored-by: Corey Bryant <[email protected]>
ajkavanagh pushed a commit to openstack-charmers/zaza-openstack-tests that referenced this pull request Mar 25, 2022
* Use yaml.safe_load()

Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650

* Use snapshot_support=True for manila share type

The extra specs of a manila share type need to match the
share service's capabilities. [1]

[1] https://docs.openstack.org/manila/pike/admin/shared-file-systems-troubleshoot.html#id2

Closes-Bug: #1962204

Co-authored-by: Felipe Reyes <[email protected]>
Co-authored-by: Corey Bryant <[email protected]>
ajkavanagh pushed a commit to openstack-charmers/zaza-openstack-tests that referenced this pull request Mar 25, 2022
* Use yaml.safe_load()

Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650

* Use snapshot_support=True for manila share type

The extra specs of a manila share type need to match the
share service's capabilities. [1]

[1] https://docs.openstack.org/manila/pike/admin/shared-file-systems-troubleshoot.html#id2

Closes-Bug: #1962204

Co-authored-by: Felipe Reyes <[email protected]>
Co-authored-by: Corey Bryant <[email protected]>
ajkavanagh pushed a commit to openstack-charmers/zaza-openstack-tests that referenced this pull request Mar 25, 2022
* Use yaml.safe_load()

Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650

* Use snapshot_support=True for manila share type

The extra specs of a manila share type need to match the
share service's capabilities. [1]

[1] https://docs.openstack.org/manila/pike/admin/shared-file-systems-troubleshoot.html#id2

Closes-Bug: #1962204

Co-authored-by: Felipe Reyes <[email protected]>
Co-authored-by: Corey Bryant <[email protected]>
ajkavanagh pushed a commit to openstack-charmers/zaza-openstack-tests that referenced this pull request Mar 25, 2022
* Use yaml.safe_load()

Pyyaml>=6.0 requires to pass the Loader arg to yaml.load(), switching to
yaml.safe_load() recovers the old and expected behavior.

yaml/pyyaml#561

Closes-Bug: #1951650

* Use snapshot_support=True for manila share type

The extra specs of a manila share type need to match the
share service's capabilities. [1]

[1] https://docs.openstack.org/manila/pike/admin/shared-file-systems-troubleshoot.html#id2

Closes-Bug: #1962204

Co-authored-by: Felipe Reyes <[email protected]>
Co-authored-by: Corey Bryant <[email protected]>
carlwgeorge added a commit to carlwgeorge/python-multipart that referenced this pull request Apr 20, 2022
yaml.load in PyYAML 6 requires a Loader argument.  PyYAML recommends
using SafeLoader, which is implied if you call yaml.safe_load instead.

yaml/pyyaml#561
https://msg.pyyaml.org/load

Fixes Kludex#41
andrew-d pushed a commit to Kludex/python-multipart that referenced this pull request Apr 20, 2022
yaml.load in PyYAML 6 requires a Loader argument.  PyYAML recommends
using SafeLoader, which is implied if you call yaml.safe_load instead.

yaml/pyyaml#561
https://msg.pyyaml.org/load

Fixes #41
daregit pushed a commit to daregit/yocto-combined that referenced this pull request May 22, 2024
Now uses "vendored" distutils from setuptools by default
rather than from Python stdlib.

Changes
=======

* yaml/pyyaml#327
  -- Change README format to Markdown
* yaml/pyyaml#483
  -- Add a test for YAML 1.1 types
* yaml/pyyaml#497
  -- fix float resolver to ignore `.` and `._`
* yaml/pyyaml#550
  -- drop Python 2.7
* yaml/pyyaml#553
  -- Fix spelling of “hexadecimal”
* yaml/pyyaml#556
  -- fix representation of Enum subclasses
* yaml/pyyaml#557
  -- fix libyaml extension compiler warnings
* yaml/pyyaml#560
  -- fix ResourceWarning on leaked file descriptors
* yaml/pyyaml#561
  -- always require `Loader` arg to `yaml.load()`
* yaml/pyyaml#564
  -- remove remaining direct distutils usage

(From OE-Core rev: 2abc7a612a71b3594f3183fbb824a708269ae694)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request May 22, 2024
Now uses "vendored" distutils from setuptools by default
rather than from Python stdlib.

Changes
=======

* yaml/pyyaml#327
  -- Change README format to Markdown
* yaml/pyyaml#483
  -- Add a test for YAML 1.1 types
* yaml/pyyaml#497
  -- fix float resolver to ignore `.` and `._`
* yaml/pyyaml#550
  -- drop Python 2.7
* yaml/pyyaml#553
  -- Fix spelling of “hexadecimal”
* yaml/pyyaml#556
  -- fix representation of Enum subclasses
* yaml/pyyaml#557
  -- fix libyaml extension compiler warnings
* yaml/pyyaml#560
  -- fix ResourceWarning on leaked file descriptors
* yaml/pyyaml#561
  -- always require `Loader` arg to `yaml.load()`
* yaml/pyyaml#564
  -- remove remaining direct distutils usage

(From OE-Core rev: 2abc7a612a71b3594f3183fbb824a708269ae694)

Signed-off-by: Tim Orling <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
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

Successfully merging this pull request may close these issues.

4 participants