Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.

Conversation

jpmens
Copy link

@jpmens jpmens commented Mar 21, 2019

PyYAML's yaml.load has been deprecated. This patch addresses that by using safe_load() in place of load()

seveas and others added 9 commits May 11, 2015 00:00
Not using the 'as' syntax, but calls to sys.exc_info is compatible with
python 2.4 and newer (maybe older as well, but I don't have one
available for testing). Tested on 2.4, 2.7 and 3.4.
- Use print(), not print
- Use IGNORE_EXCEPTION_DETAIL to make exception testing tests not fail.
  In python 3, you would see 'beanstalkc.CommandFailed' instead of
  'CommandFailed', this option makes tests pass regardless.

Tested with python 2.7 and python3.
Note that this does _not_ demonstrate or test for full 8-bit
transparency across implementations. (beanstalkc-to-beanstalkc could
still easily pass this by using a fully revertible internal encoding.)

However, this example should already be sufficient to illustrate a
design issue for beanstalkc Python 3 adaptations. It should also be a
good additional sanity check (even when ignoring 8-bit transparency), as
the length of the job data in Unicode codepoints no longer equals the
length in bytes after encoding via e.g. UTF-8:

    >>> data = '\x00\x01\xfe\xff'
    >>> len(data)
    4
    >>> len(data.encode('utf-8'))
    6
Under python3, we are responsible for decoding and encoding. The
implementation does not change the behaviour for python 2, and by
default uses python2-esque behaviour (using sys.getdefaultencoding())
under python 3, but lets the user override the encoding or even set it
to None to get bytes objects back. It also allows the user to pass bytes
objects to put, striking the best balance between backwards
compatibility for binary data in tubes (which can never be achieved
100%) and working nicely with text data.

Tested with python 2.4, 2.7 and 3.4
@kshtsk
Copy link

kshtsk commented Oct 9, 2019

Hey guys any update regarding safe_load deprecation?

@seveas seveas closed this Mar 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants