You've already forked gnatcoll-bindings
mirror of
https://github.com/AdaCore/gnatcoll-bindings.git
synced 2026-02-12 12:59:11 -08:00
python3 compatibility: file interface
Document that python3 removes PyFile_FromString, but provide a wrapper if python3 is in use. Part of S821-014 Change-Id: I2aeeef23be667810a39004d028f16c60889e9656
This commit is contained in:
committed by
Nicolas Roche
parent
b508bcf68b
commit
f47dbd0271
@@ -1,7 +1,7 @@
|
||||
/*----------------------------------------------------------------------------
|
||||
-- G N A T C O L L --
|
||||
-- --
|
||||
-- Copyright (C) 2003-2019, AdaCore --
|
||||
-- Copyright (C) 2003-2020, AdaCore --
|
||||
-- --
|
||||
-- This is free software; you can redistribute it and/or modify it under --
|
||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||
@@ -886,6 +886,16 @@ PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr(
|
||||
(PyCapsule_Destructor) destruct);
|
||||
};
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFile_FromString
|
||||
(const char *file_name, const char *mode)
|
||||
{
|
||||
PyObject * io = PyImport_ImportModule ("io");
|
||||
if (io == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return PyObject_CallMethod (io, "open", "ss", file_name, mode);
|
||||
}
|
||||
|
||||
#else
|
||||
int ada_is_python3() {
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user