summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2013-10-08 18:46:37 +0200
committerJulian Andres Klode <jak@debian.org>2013-10-08 21:55:15 +0200
commit9305bd3ff845eb61649767b86688bb36b54d9437 (patch)
tree901bb0cb8a76d568640ae3f73ae0a30be85cc4a7
parentd0739a17f824a7bf3cfa217223b88979c571e7dd (diff)
downloadpython-apt-9305bd3ff845eb61649767b86688bb36b54d9437.tar.gz
python/generic.cc: Move PyApt_Filename::init here
-rw-r--r--python/generic.cc23
-rw-r--r--python/generic.h22
2 files changed, 24 insertions, 21 deletions
diff --git a/python/generic.cc b/python/generic.cc
index 8e65c4f3..5e712899 100644
--- a/python/generic.cc
+++ b/python/generic.cc
@@ -93,3 +93,26 @@ PyObject *CharCharToList(const char **List,unsigned long Size)
return PList;
}
/*}}}*/
+
+int PyApt_Filename::init(PyObject *object)
+{
+ this->object = NULL;
+ this->path = NULL;
+
+#if PY_MAJOR_VERSION < 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 2)
+ this->path = PyObject_AsString(object);
+ return this->path ? 1 : 0;
+#else
+ if (PyUnicode_Check(object)) {
+ object = PyUnicode_EncodeFSDefault(object);
+ } else if (PyBytes_Check(object)) {
+ Py_INCREF(object);
+ } else {
+ return 0;
+ }
+
+ this->object = object;
+ this->path = PyBytes_AS_STRING(this->object);
+ return 1;
+#endif
+}
diff --git a/python/generic.h b/python/generic.h
index 7dc89ca6..c9db916c 100644
--- a/python/generic.h
+++ b/python/generic.h
@@ -269,27 +269,7 @@ public:
path = NULL;
}
- int init(PyObject *object) {
- this->object = NULL;
- this->path = NULL;
-
-#if PY_MAJOR_VERSION < 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 2)
- this->path = PyObject_AsString(object);
- return this->path ? 1 : 0;
-#else
- if (PyUnicode_Check(object)) {
- object = PyUnicode_EncodeFSDefault(object);
- } else if (PyBytes_Check(object)) {
- Py_INCREF(object);
- } else {
- return 0;
- }
-
- this->object = object;
- this->path = PyBytes_AS_STRING(this->object);
- return 1;
-#endif
- }
+ int init(PyObject *object);
~PyApt_Filename() {
Py_XDECREF(object);