summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3-cython/0001-Output-import-relative-paths-in-generated-C-code.-GH.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/python/python3-cython/0001-Output-import-relative-paths-in-generated-C-code.-GH.patch')
-rw-r--r--meta/recipes-devtools/python/python3-cython/0001-Output-import-relative-paths-in-generated-C-code.-GH.patch73
1 files changed, 0 insertions, 73 deletions
diff --git a/meta/recipes-devtools/python/python3-cython/0001-Output-import-relative-paths-in-generated-C-code.-GH.patch b/meta/recipes-devtools/python/python3-cython/0001-Output-import-relative-paths-in-generated-C-code.-GH.patch
deleted file mode 100644
index bbafc29416..0000000000
--- a/meta/recipes-devtools/python/python3-cython/0001-Output-import-relative-paths-in-generated-C-code.-GH.patch
+++ /dev/null
@@ -1,73 +0,0 @@
1From 9b5f3b09f76899eba510c2d8f3ed2b0f752a4d1b Mon Sep 17 00:00:00 2001
2From: Oscar Benjamin <oscar.j.benjamin@gmail.com>
3Date: Sat, 24 Aug 2024 08:30:31 +0100
4Subject: [PATCH] Output import-relative paths in generated C code. (GH-6341)
5
6When cython is run on a file that is not in the current working directory,
7it outputs filepaths that are either absolute or are basenames.
8It is not good to output absolute paths in the generated C code and
9basenames mess up coverage measurement.
10
11Upstream-Status: Backport [20bceea6b19ffc2f65b9fba2e4f737f09e5a2b20]
12Signed-off-by: Ross Burton <ross.burton@arm.com>
13---
14 Cython/Compiler/ExprNodes.py | 8 +++++++-
15 Cython/Compiler/ModuleNode.py | 9 ++++++---
16 2 files changed, 13 insertions(+), 4 deletions(-)
17
18diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py
19index a6bb1688e..0fbb15368 100644
20--- a/Cython/Compiler/ExprNodes.py
21+++ b/Cython/Compiler/ExprNodes.py
22@@ -21,6 +21,7 @@ import re
23 import sys
24 import copy
25 import os.path
26+import pathlib
27 import operator
28
29 from .Errors import (
30@@ -10072,7 +10073,12 @@ class CodeObjectNode(ExprNode):
31 func_name = code.get_py_string_const(
32 func.name, identifier=True, is_str=False, unicode_value=func.name)
33 # FIXME: better way to get the module file path at module init time? Encoding to use?
34- file_path = StringEncoding.bytes_literal(func.pos[0].get_filenametable_entry().encode('utf8'), 'utf8')
35+ file_path = func.pos[0].get_filenametable_entry()
36+ if os.path.isabs(file_path):
37+ file_path = func.pos[0].get_description()
38+ # Always use / as separator
39+ file_path = pathlib.Path(file_path).as_posix()
40+ file_path = StringEncoding.bytes_literal(file_path.encode('utf-8'), 'utf8')
41 file_path_const = code.get_py_string_const(file_path, identifier=False, is_str=True)
42
43 # This combination makes CPython create a new dict for "frame.f_locals" (see GH #1836).
44diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py
45index 43c6b5f07..8c29d6db7 100644
46--- a/Cython/Compiler/ModuleNode.py
47+++ b/Cython/Compiler/ModuleNode.py
48@@ -13,6 +13,7 @@ from collections import defaultdict
49 import json
50 import operator
51 import os
52+import pathlib
53 import re
54 import sys
55
56@@ -944,9 +945,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
57 for source_desc in code.globalstate.filename_list:
58 file_path = source_desc.get_filenametable_entry()
59 if isabs(file_path):
60- file_path = basename(file_path) # never include absolute paths
61- escaped_filename = file_path.replace("\\", "\\\\").replace('"', r'\"')
62- escaped_filename = as_encoded_filename(escaped_filename)
63+ # never include absolute paths
64+ file_path = source_desc.get_description()
65+ # Always use / as separator
66+ file_path = pathlib.Path(file_path).as_posix()
67+ escaped_filename = as_encoded_filename(file_path)
68 code.putln('%s,' % escaped_filename.as_c_string_literal())
69 else:
70 # Some C compilers don't like an empty array
71--
722.34.1
73