summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/File.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-10-15 19:35:48 +0000
committerZachary Turner <zturner@google.com>2015-10-15 19:35:48 +0000
commit9c40264fdadbb229ce311c9bda898981d7ac8eae (patch)
tree93437006427295b7cd98fd7e8a3ddd14a4410b9f /lldb/source/Host/common/File.cpp
parentb26d8070333117beb92bde3007ddd37729929c3e (diff)
downloadbcm5719-llvm-9c40264fdadbb229ce311c9bda898981d7ac8eae.tar.gz
bcm5719-llvm-9c40264fdadbb229ce311c9bda898981d7ac8eae.zip
Introduce a `PythonFile` object, and use it everywhere.
Python file handling got an overhaul in Python 3, and it affects the way we have to interact with files. Notably: 1) `PyFile_FromFile` no longer exists, and instead we have to use `PyFile_FromFd`. This means having a way to get an fd from a FILE*. For this we reuse the lldb_private::File class to convert between FILE*s and fds, since there are some subtleties regarding ownership rules when FILE*s and fds refer to the same file. 2) PyFile is no longer a builtin type, so there is no such thing as `PyFile_Check`. Instead, files in Python 3 are just instances of `io.IOBase`. So the logic for checking if something is a file in Python 3 is to check if it is a subclass of that module. Additionally, some unit tests are added to verify that `PythonFile` works as expected on Python 2 and Python 3, and `ScriptInterpreterPython` is updated to use `PythonFile` instead of manual calls to the various `PyFile_XXX` methods. llvm-svn: 250444
Diffstat (limited to 'lldb/source/Host/common/File.cpp')
-rw-r--r--lldb/source/Host/common/File.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp
index a3420bff65f..a3d7bf5940c 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -143,7 +143,13 @@ File::GetDescriptor() const
// Don't open the file descriptor if we don't need to, just get it from the
// stream if we have one.
if (StreamIsValid())
- return fileno (m_stream);
+ {
+#if defined(LLVM_ON_WIN32)
+ return _fileno(m_stream);
+#else
+ return fileno(m_stream);
+#endif
+ }
// Invalid descriptor and invalid stream, return invalid descriptor.
return kInvalidDescriptor;
OpenPOWER on IntegriCloud