Skip to content

Commit

Permalink
#1291: (BACKWARD-INCOMPATIBLE) remove memory_maps() on OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Feb 28, 2019
1 parent 59e3c5e commit 4a283d6
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 30 deletions.
6 changes: 3 additions & 3 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ XXXX-XX-XX
- 1439_: [NetBSD] Process.connections() may return incomplete results if using
oneshot()

**API changes**
**Incompatible API changes**

- 1291_: [OSX] Process.memory_maps() is deprecated and will always raise
AccessDenied. It will be removed in psutil 6.0.0.
- 1291_: [OSX] Process.memory_maps() was removed because inherently broken
(segfault) for years.

5.5.1
=====
Expand Down
9 changes: 2 additions & 7 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1708,14 +1708,9 @@ Process class

Availability: Linux, Windows, FreeBSD, SunOS

.. warning::
on macOS, starting from version 5.6.0, this function is deprecated and
will always raise :class:`psutil.AccessDenied`. It is scheduled for
removal in 6.0.0
(see `issue 1020 <https://github.com/giampaolo/psutil/issues/1291#issuecomment-467828376>`_).

.. versionchanged::
5.6.0 deprecated on macOS, always raise AccessDenied
5.6.0 removed macOS support because inherently broken (see
issue `#1291 <https://github.com/giampaolo/psutil/issues/1291>`__)

.. method:: children(recursive=False)

Expand Down
6 changes: 0 additions & 6 deletions psutil/_psosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import errno
import functools
import os
import warnings
from socket import AF_INET
from collections import namedtuple

Expand Down Expand Up @@ -575,8 +574,3 @@ def threads(self):
ntuple = _common.pthread(thread_id, utime, stime)
retlist.append(ntuple)
return retlist

def memory_maps(self):
msg = "memory_maps() on OSX is deprecated and will be removed in 6.0.0"
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
raise AccessDenied(self.pid, msg=msg)
2 changes: 1 addition & 1 deletion psutil/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
HAS_PROC_IO_COUNTERS = hasattr(psutil.Process, "io_counters")
HAS_IONICE = hasattr(psutil.Process, "ionice")
HAS_MEMORY_FULL_INFO = 'uss' in psutil.Process().memory_full_info()._fields
HAS_MEMORY_MAPS = not MACOS and hasattr(psutil.Process, "memory_maps")
HAS_MEMORY_MAPS = hasattr(psutil.Process, "memory_maps")
HAS_PROC_CPU_NUM = hasattr(psutil.Process, "cpu_num")
HAS_RLIMIT = hasattr(psutil.Process, "rlimit")
HAS_THREADS = hasattr(psutil.Process, "threads")
Expand Down
11 changes: 2 additions & 9 deletions psutil/tests/test_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def test_proc_cpu_num(self):

def test_proc_memory_maps(self):
hasit = hasattr(psutil.Process, "memory_maps")
self.assertEqual(hasit, False if OPENBSD or NETBSD or AIX else True)
self.assertEqual(
hasit, False if OPENBSD or NETBSD or AIX or MACOS else True)


# ===================================================================
Expand All @@ -185,14 +186,6 @@ def test_memory_info_ex(self):
self.assertIn("memory_info_ex() is deprecated", str(w.message))
self.assertIn("use memory_info() instead", str(w.message))

@unittest.skipIf(not MACOS, "deprecated on macOS")
def test_memory_maps_osx(self):
with warnings.catch_warnings(record=True) as ws:
with self.assertRaises(psutil.AccessDenied):
psutil.Process().memory_maps()
w = ws[0]
self.assertIsInstance(w.category(), DeprecationWarning)


# ===================================================================
# --- System API types
Expand Down
2 changes: 0 additions & 2 deletions psutil/tests/test_memory_leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,6 @@ def test_open_files(self):
with open(TESTFN, 'w'):
self.execute(self.proc.open_files)

# MACOS implementation is unbelievably slow
@unittest.skipIf(MACOS, "too slow on MACOS")
@unittest.skipIf(not HAS_MEMORY_MAPS, "not supported")
@skip_if_linux()
def test_memory_maps(self):
Expand Down
2 changes: 0 additions & 2 deletions psutil/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,8 +1291,6 @@ def test_halfway_terminated_process(self):
ret = meth([0])
elif name == 'send_signal':
ret = meth(signal.SIGTERM)
elif MACOS and name == 'memory_maps':
continue # XXX
else:
ret = meth()
except psutil.ZombieProcess:
Expand Down

0 comments on commit 4a283d6

Please sign in to comment.