Skip to content

Commit

Permalink
Fix stub compat with older pyyaml versions that may unwittingly load it
Browse files Browse the repository at this point in the history
  • Loading branch information
nitzmahone authored and ingydotnet committed Jan 20, 2021
1 parent 58d0cb7 commit 2b37f15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/_yaml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# close enough for anyone who's relying on it even when they shouldn't.
import yaml

if not yaml.__with_libyaml__:
# in some circumstances, the yaml module we imoprted may be from a different version, so we need
# to tread carefully when poking at it here (it may not have the attributes we expect)
if not getattr(yaml, '__with_libyaml__', False):
from sys import version_info

exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError
Expand Down
4 changes: 3 additions & 1 deletion lib3/_yaml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# close enough for anyone who's relying on it even when they shouldn't.
import yaml

if not yaml.__with_libyaml__:
# in some circumstances, the yaml module we imoprted may be from a different version, so we need
# to tread carefully when poking at it here (it may not have the attributes we expect)
if not getattr(yaml, '__with_libyaml__', False):
from sys import version_info

exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError
Expand Down

0 comments on commit 2b37f15

Please sign in to comment.