MSYS2-packages/python-pyalpm/0002-Python2-compat-Use-Py_BuildValue-s-file-name.patch
Ray Donnelly ff90f3b627 pyalpm: New package
Python wrapper for libalpm and python implementation of
pacman (pycman). Backported to Python 2.
2016-03-12 15:50:58 +00:00

30 lines
1.0 KiB
Diff

From c9bd0894ab16050c318a61e96f5e65b6cd58322c Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Fri, 11 Mar 2016 11:56:57 +0000
Subject: [PATCH 2/5] Python2 compat: Use Py_BuildValue("s", file->name)
.. since PyUnicode_DecodeFSDefault() isn't available
---
src/package.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git src/package.c src/package.c
index d4ab941..909cb0d 100644
--- src/package.c
+++ src/package.c
@@ -213,7 +213,11 @@ static PyObject* pyalpm_package_get_files(AlpmPackage *self, void *closure) {
result = PyList_New((Py_ssize_t)flist->count);
for (i = 0; i < (ssize_t)flist->count; i++) {
const alpm_file_t *file = flist->files + i;
+#if PY_MAJOR_VERSION >= 3
PyObject *filename = PyUnicode_DecodeFSDefault(file->name);
+#else
+ PyObject *filename = Py_BuildValue("s", file->name);
+#endif
PyObject *filesize = PyLong_FromLongLong(file->size);
PyObject *filemode = PyLong_FromUnsignedLong(file->mode);
PyObject *item = PyTuple_New(3);
--
2.7.1