diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-04-15 16:19:12 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-04-15 16:19:12 +0200 |
| commit | c876c5095673a2f1c0f2c0eef6eadef2ce200e19 (patch) | |
| tree | f0832dbbdeb688e0176294e9b487f996108555ad /python/string.cc | |
| parent | 97d985d73d12da5578628418aa787d78a33b652d (diff) | |
| download | python-apt-c876c5095673a2f1c0f2c0eef6eadef2ce200e19.tar.gz | |
* Introduce support for Python 3 (Closes: #523645)
This is the first initial port to Python 3. The API is almost completely
identical to the one found in Python 2, except that functions working with
binary data require bytes (md5sum,sha1sum,sha256sum,Base64Encode).
Using setup3.py to install the modules will not work, because the apt package
still has to be converted to Python 3. For the package, we call 2to3-3.1 in
debian/rules to do this automatically.
Diffstat (limited to 'python/string.cc')
| -rw-r--r-- | python/string.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/python/string.cc b/python/string.cc index 8168ea5b..b95ee3eb 100644 --- a/python/string.cc +++ b/python/string.cc @@ -38,7 +38,21 @@ PyObject *Python(PyObject *Self,PyObject *Args) \ } MkStr(StrDeQuote,DeQuoteString); -MkStr(StrBase64Encode,Base64Encode); + +/* + * Input bytes(Py3k)/str(Py2), output str. + */ +PyObject *StrBase64Encode(PyObject *Self,PyObject *Args) { + char *Str = 0; + #if PY_MAJOR_VERSION >= 3 + if (PyArg_ParseTuple(Args,"y",&Str) == 0) + #else + if (PyArg_ParseTuple(Args,"s",&Str) == 0) + #endif + return 0; + return CppPyString(Base64Encode(Str)); +} + MkStr(StrURItoFileName,URItoFileName); //MkFloat(StrSizeToStr,SizeToStr); |
