blob: 4f0afda395670098a5d72bd30f497f086393cb12 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
Author: Michael R. Crusoe <crusoe@debian.org>, Julian Gilbey <jdg@debian.org>
Description: Default to pure python parsing on big endian systems
The current version fails on big-endian systems as described in
https://sourceforge.net/p/ruamel-yaml/tickets/360/ and
https://sourceforge.net/p/ruamel-yaml-clib/tickets/34/
.
The current version of this patch completely disables the C extension on
big-endian systems.
.
Thanks to Rebecca N. Palmer for the tip about sys.byteorder!
Forwarded: not-needed
Last-Update: 2024-04-18
--- a/__init__.py
+++ b/__init__.py
@@ -1,4 +1,5 @@
from __future__ import annotations
+import sys
if False: # MYPY
@@ -47,11 +47,13 @@
version_info = _package_data['version_info']
__version__ = _package_data['__version__']
-try:
- from .cyaml import * # NOQA
-
- __with_libyaml__ = True
-except (ImportError, ValueError): # for Jython
- __with_libyaml__ = False
+__with_libyaml__ = False
+if sys.byteorder == "little":
+ try:
+ from .cyaml import * # NOQA
+
+ __with_libyaml__ = True
+ except (ImportError, ValueError): # for Jython
+ pass
from ruamel.yaml.main import * # NOQA
--- a/_test/test_cyaml.py
+++ b/_test/test_cyaml.py
@@ -7,6 +7,10 @@
NO_CLIB_VER = (3, 12)
+pytestmark = pytest.mark.skipif(
+ sys.byteorder == "big",
+ reason="compiled library disabled on big-endian machines"
+)
@pytest.mark.skipif( # type: ignore
platform.python_implementation() in ['Jython', 'PyPy'],
|