Commit Graph

343 Commits

Author SHA1 Message Date
Filip Salomonsson
5a0cfab86f Fix handling of __slots__ (#161) 2019-12-07 22:34:23 +01:00
Tim Gates
eb459f842f Fix up small typo
Replace `intendation` with `indentation`.
2019-12-04 00:31:05 +01:00
Sergey Fursov
e21af4a092 Use is instead of equality for comparing with None 2019-12-04 00:04:05 +01:00
David Kao
de11e43d52 fix typos and stylistic nit 2019-12-03 23:58:55 +01:00
Christian Clauss
a7a97871fc fixup! setup.py: python_requires='!=3.4.*', 2019-12-03 23:38:13 +01:00
Christian Clauss
039c9eb308 setup.py: Remove support for EOL Python 3.4 2019-12-03 23:38:13 +01:00
Christian Clauss
6544c3091f tox.ini: Add py38 and remove py34 2019-12-03 23:38:13 +01:00
Christian Clauss
6d854b1e30 Travis CI: Test on Python 3.8 production release
Also drop the EOL Python 3.4  @hugovk Your review please.
2019-12-03 23:38:13 +01:00
Tina Müller
15e0e80d6d Fix appveyor.yml to use libyaml tag not branch 2019-12-03 23:36:50 +01:00
Tina Müller
a5c2a043a2 Version 5.2 2019-12-02 21:13:24 +01:00
Matt Davis
f4fd3fbf87 Windows build tweaks
* centralized error handling on native commands
* ensure that errors from native commands will fail build
* use image-included Python 3.8
* drop Python 3.4 wheel builds
2019-11-27 23:00:21 +01:00
Tina Müller
f813bc00f5 Changes for 5.2b1 2019-11-25 23:39:55 +01:00
Matt Davis
3f3c373f50 bump version to 5.2b1 2019-11-25 23:39:55 +01:00
Tina Müller
8c5e47fe62 Move constructor for object/apply to Unsafe 2019-11-20 20:48:47 +01:00
Tina Müller
4a31b16b04 Change default loader for add_implicit_resolver, add_path_resolver
If the Loader parameter is not given, add constructor to
all three loaders
2019-11-18 12:28:20 +01:00
Ingy döt Net
a5394c04a2 Add custom constructors to multiple loaders
When someone writes a subclass of the YAMLObject class, the constructors
will now be added to all 3 (non-safe) loaders.

Furthermore, we support the class variable `yaml_loader` being a list,
offering more control of which loaders are affected.

To support safe_load in your custom class you could add this:

    yaml_loader = yaml.SafeLoader

    yaml_loader = yaml.YAMLObject.yaml_loader
    yaml_loader.append(yaml.SafeLoader)
2019-11-18 11:59:54 +01:00
Tina Müller (tinita)
8d7a78003a Change default loader for yaml.add_constructor (#287)
* Change default loader for yaml.add_constructor

If the Loader parameter is not given, add constructor to
all three loaders
2019-11-18 11:59:54 +01:00
Tina Müller (tinita)
8a7d0ed162 Update CHANGES for 5.1 (#280)
* Update CHANGES

Some PRs were forgotten, and some were listed that weren't merged.
2019-11-18 11:59:54 +01:00
Tina Müller (tinita)
31f2279252 Fix logic for quoting special characters (#276)
* Fix logic for quoting special characters

* Remove has_ucs4 from condition

on systems with `sys.maxunicode <= 0xffff` the comparison
(u'\U00010000' <= ch < u'\U0010ffff') can't be true anyway I think
2019-11-18 11:59:54 +01:00
Matt Davis
0f64cbfa54 changes for 5.1.2 release 2019-07-30 18:21:30 -07:00
Matt Davis
5986257f9f changes for 5.1.1 release 2019-06-06 15:14:10 -07:00
Ingy döt Net
e471e86bf6 Updates for 5.1 release 2019-03-13 08:45:34 -07:00
Matt Davis
9141e900d1 Windows Appveyor build
* builds Windows wheels against a specified libyaml repo/refspec for many Python versions
* since we don't have multiple Appveyor workers, it's faster/more convenient to run them serially
* not all paths sufficient for general CI usage yet; still needs manual inspection/testing of output
* various hacks to quiet warning noise during build on old Pythons
2019-03-12 16:22:31 -07:00
Tina Müller
d6cbff6620 Skip certain unicode tests when maxunicode not > 0xffff 2019-03-12 16:22:31 -07:00
Ingy döt Net
69103ba255 Update .travis.yml to use libyaml 0.2.2 2019-03-12 16:22:20 -07:00
Matt Davis
91c9435bb6 Squash/merge pull request #105 from nnadeau/patch-1
Removed Python 2.6 & 3.3
2019-03-08 09:09:48 -08:00
Tina Müller
507a464ce6 Make default_flow_style=False 2019-03-08 09:09:48 -08:00
Tina Müller
07c88c6c1b Allow to turn off sorting keys in Dumper 2019-03-08 09:09:48 -08:00
Jon Dufresne
611ba39507 Include license file in the generated wheel package
The wheel package format supports including the license file. This is
done using the [metadata] section in the setup.cfg file. For additional
information on this feature, see:

https://wheel.readthedocs.io/en/stable/index.html#including-the-license-in-the-generated-wheel-file

Distributing the wheel now complies with the license:

> The above copyright notice and this permission notice shall be
> included in all copies or substantial portions of the Software.
2019-03-08 09:09:48 -08:00
Tina Müller
857dff153d Apply FullLoader/UnsafeLoader changes to lib3 2019-03-08 09:09:48 -08:00
Ingy döt Net
0cedb2a069 Deprecate/warn usage of yaml.load(input)
The `load` and `load_all` methods will issue a warning when they are
called without the 'Loader=' parameter. The warning will point to a URL
that is always up to date with the latest information on the usage of
`load`.

There are several ways to stop the warning:

* Use `full_load(input)` - sugar for `yaml.load(input, FullLoader)`
  * FullLoader is the new safe but complete loader class
* Use `safe_load(input)` - sugar for `yaml.load(input, SafeLoader)`
  * Make sure your input YAML consists of the 'safe' subset
* Use `unsafe_load(input)` - sugar for `yaml.load(input, UnsafeLoader)`
  * Make sure your input YAML consists of the 'safe' subset
* Use `yaml.load(input, Loader=yaml.<loader>)`
  * Or shorter `yaml.load(input, yaml.<loader>)`
  * Where '<loader>' can be:
    * FullLoader - safe, complete Python YAML loading
    * SafeLoader - safe, partial Python YAML loading
    * UnsafeLoader - more explicit name for the old, unsafe 'Loader' class
* yaml.warnings({'YAMLLoadWarning': False})
  * Use this when you use third party modules that use `yaml.load(input)`
  * Only do this if input is trusted

The above `load()` expressions all have `load_all()` counterparts.

You can get the original unsafe behavior with:
* `yaml.unsafe_load(input)`
* `yaml.load(input, Loader=yaml.UnsafeLoader)`

In a future release, `yaml.load(input)` will raise an exception.

The new loader called FullLoader is almost entirely complete as
Loader/UnsafeLoader but it does it avoids all known code execution
paths. It is the preferred YAML loader, and the current default for
`yaml.load(input)` when you get the warning.

Here are some of the exploits that can be triggered with UnsafeLoader
but not with FullLoader:
```
python -c 'import os, yaml; yaml.full_load("!!python/object/new:os.system [echo EXPLOIT!]")'`
python -c 'import yaml; print yaml.full_load("!!python/object/new:abs [-5]")'
python -c 'import yaml; yaml.full_load("!!python/object/new:eval [exit(5)]")' ; echo $?
python -c 'import yaml; yaml.full_load("!!python/object/new:exit [5]")' ; echo $?
2019-03-08 09:09:48 -08:00
scauligi
d13a3d0f96 Fix for bug https://github.com/yaml/pyyaml/issues/118 2019-02-27 18:07:29 -08:00
Florian Bruhin
9959328b41 Import Hashable from collections.abc
In Python 3.7, importing ABCs directly from the 'collections' module shows a
warning (and in Python 3.8 it will stop working) - see
c66f9f8d39

Since this is only done in lib3/ which is Python 3 only, we can unconditionally
import it from collections.abc instead.

This fixes the following DeprecationWarning:

.../site-packages/yaml/__init__.py:75: in load
    return loader.get_single_data()
.../site-packages/yaml/constructor.py:37: in get_single_data
    return self.construct_document(node)
.../site-packages/yaml/constructor.py:46: in construct_document
    for dummy in generator:
.../site-packages/yaml/constructor.py:398: in construct_yaml_map
    value = self.construct_mapping(node)
.../site-packages/yaml/constructor.py:204: in construct_mapping
    return super().construct_mapping(node, deep=deep)
.../site-packages/yaml/constructor.py:126: in construct_mapping
    if not isinstance(key, collections.Hashable):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

name = 'Hashable'

    def __getattr__(name):
        # For backwards compatibility, continue to make the collections ABCs
        # through Python 3.6 available through the collections module.
        # Note, no new collections ABCs were added in Python 3.7
        if name in _collections_abc.__all__:
            obj = getattr(_collections_abc, name)
            import warnings
            warnings.warn("Using or importing the ABCs from 'collections' instead "
                          "of from 'collections.abc' is deprecated, "
                          "and in 3.8 it will stop working",
>                         DeprecationWarning, stacklevel=2)
E           DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
2019-02-27 18:06:38 -08:00
Ingy döt Net
ccc40f3e2b Reverting https://github.com/yaml/pyyaml/pull/74
Revert "Make pyyaml safe by default."

This reverts commit bbcf95fa05.
This reverts commit 7b68405c81.
This reverts commit 517e83e805.
2018-06-30 15:46:56 -07:00
Tina Müller
a9c28e0b52 Build libyaml on travis 2018-06-30 15:42:55 -07:00
Anthony Sottile
69244c1cb5 Install cython alongside tox 2018-06-30 22:49:26 +02:00
Tina Müller
d76d037119 Force cython when building sdist
Fixes #182
2018-06-30 22:49:22 +02:00
Alex Gaynor
d3eb7daf88 Changes for 4.1 release 2018-06-26 15:08:15 -07:00
Ingy döt Net
4c2e993321 Changes for 4.01 release
This is the first release under new maintainership. A bunch of things
involving resource URLs and copyright details needed updating; in
addition to the normal version and changelog updates.
2018-06-24 17:08:57 -06:00
Tina Müller
f6049c8cd6 Support escaped slash in double quotes "\/"
YAML 1.2 JSON compat
2018-06-24 22:15:31 +02:00
hugovk
e7a2f886d9 Drop unsupported Python 3.3
See: https://en.wikipedia.org/wiki/CPython#Version_history
2018-06-24 13:49:12 -06:00
Hugo
b6cbfeec35 Test on Python 3.7-dev
Add Python 3.7 classifier
2018-04-11 10:20:16 -07:00
Jon Dufresne
801288d796 Remove commented out Psyco code
From the Psyco website:

> 12 March 2012
>
> Psyco is unmaintained and dead. Please look at PyPy for the
> state-of-the-art in JIT compilers for Python.

http://psyco.sourceforge.net/
2018-04-11 10:02:31 -07:00
Ingy döt Net
0f2afdea77 Revert PR #150 per @asomov
and also explicitly return None if no tokens exist.

Also add a comment to show this.

This 'None' behavior should be tested at some point.
2018-04-10 16:51:43 -07:00
Andrey Somov
a02d17a027 Remove redundant code in Scanner.peek_token() 2018-03-28 10:07:27 +02:00
Donald Stufft
298e07907a Fallback to Pure Python if Compilation fails
Originally this code attempted to determine if compiling the C ext
would succeed, and if it thought it should, it would then require that
the C extension succeed in order to install. This fails in cases where
the detection code passes, but compiling ultimately fails (one instance
this might happen is if the Python headers are not installed).

Instead of "asking permission", this code will now just attempt to
compile the module, and will fall back to pure Python if that fails,
unless the person has explicitly asked for the C module, in which case
it will still just fail.
2017-09-11 19:23:05 -05:00
hsmtkk
802c4a6dac add 3.12 changelog 2017-09-11 19:22:44 -05:00
Alex Gaynor
bbcf95fa05 Now, for py3k! 2017-08-26 10:26:01 -05:00
Alex Gaynor
517e83e805 wtf, how did this typo happen 2017-08-26 10:26:01 -05:00
Alex Gaynor
7b68405c81 Make pyyaml safe by default.
Change yaml.load/yaml.dump to be yaml.safe_load/yaml.safe_dump, introduced yaml.danger_dump/yaml.danger_load, and the same for various other classes.

(python2 only at this moment)

Refs #5
2017-08-26 10:26:01 -05:00