prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  circuit -> schedule raises exception
  <!-- ⚠️ If you do not respect this template, your issue will be closed -->
  <!-- ⚠️ Make sure to browse the opened and closed issues -->
  
  ### Information
  
  - **Qiskit Terra version**: master
  - **Python version**:
  - **Operating system**:
  
  ### What is the current behavior?
  ```python
  ghz = QuantumCircuit(5, 5)
  ghz.h(0)
  ghz.cx(range(4), range(1,5))
  ghz.barrier()
  ghz.measure(range(5), range(5))
  
  sch = schedule(ghz, backend)
  ```
  
  gives:
  
  AttributeError: 'NoneType' object has no attribute 'instruction_schedule_map'
  
  This works on older versions.
  
  
  ### Steps to reproduce the problem
  
  
  
  ### What is the expected behavior?
  
  
  
  ### Suggested solutions
  
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `qiskit/compiler/schedule.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 
  3 # This code is part of Qiskit.
  4 #
  5 # (C) Copyright IBM 2019.
  6 #
  7 # This code is licensed under the Apache License, Version 2.0. You may
  8 # obtain a copy of this license in the LICENSE.txt file in the root directory
  9 # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
  10 #
  11 # Any modifications or derivative works of this code must retain this
  12 # copyright notice, and modified files need to carry a notice indicating
  13 # that they have been altered from the originals.
  14 
  15 """
  16 Convenience entry point into pulse scheduling, requiring only a circuit and a backend. For more
  17 control over pulse scheduling, look at `qiskit.scheduler.schedule_circuit`.
  18 """
  19 import logging
  20 
  21 from time import time
  22 from typing import List, Optional, Union
  23 
  24 from qiskit.circuit.quantumcircuit import QuantumCircuit
  25 from qiskit.exceptions import QiskitError
  26 from qiskit.pulse import InstructionScheduleMap, Schedule
  27 from qiskit.providers import BaseBackend
  28 from qiskit.scheduler import ScheduleConfig
  29 from qiskit.scheduler.schedule_circuit import schedule_circuit
  30 
  31 LOG = logging.getLogger(__name__)
  32 
  33 
  34 def _log_schedule_time(start_time, end_time):
  35     log_msg = "Total Scheduling Time - %.5f (ms)" % ((end_time - start_time) * 1000)
  36     LOG.info(log_msg)
  37 
  38 
  39 def schedule(circuits: Union[QuantumCircuit, List[QuantumCircuit]],
  40              backend: Optional[BaseBackend] = None,
  41              inst_map: Optional[InstructionScheduleMap] = None,
  42              meas_map: Optional[List[List[int]]] = None,
  43              method: Optional[Union[str, List[str]]] = None) -> Union[Schedule, List[Schedule]]:
  44     """
  45     Schedule a circuit to a pulse ``Schedule``, using the backend, according to any specified
  46     methods. Supported methods are documented in :py:mod:`qiskit.scheduler.schedule_circuit`.
  47 
  48     Args:
  49         circuits: The quantum circuit or circuits to translate
  50         backend: A backend instance, which contains hardware-specific data required for scheduling
  51         inst_map: Mapping of circuit operations to pulse schedules. If ``None``, defaults to the
  52                   ``backend``\'s ``instruction_schedule_map``
  53         meas_map: List of sets of qubits that must be measured together. If ``None``, defaults to
  54                   the ``backend``\'s ``meas_map``
  55         method: Optionally specify a particular scheduling method
  56 
  57     Returns:
  58         A pulse ``Schedule`` that implements the input circuit
  59 
  60     Raises:
  61         QiskitError: If ``inst_map`` and ``meas_map`` are not passed and ``backend`` is not passed
  62     """
  63     start_time = time()
  64     if inst_map is None:
  65         if backend is None:
  66             raise QiskitError("Must supply either a backend or InstructionScheduleMap for "
  67                               "scheduling passes.")
  68         inst_map = backend.defaults().instruction_schedule_map
  69     if meas_map is None:
  70         if backend is None:
  71             raise QiskitError("Must supply either a backend or a meas_map for scheduling passes.")
  72         meas_map = backend.configuration().meas_map
  73 
  74     schedule_config = ScheduleConfig(inst_map=inst_map, meas_map=meas_map)
  75     circuits = circuits if isinstance(circuits, list) else [circuits]
  76     schedules = [schedule_circuit(circuit, schedule_config, method) for circuit in circuits]
  77     end_time = time()
  78     _log_schedule_time(start_time, end_time)
  79     return schedules[0] if len(schedules) == 1 else schedules
  80
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/qiskit/compiler/schedule.py b/qiskit/compiler/schedule.py
  --- a/qiskit/compiler/schedule.py
  +++ b/qiskit/compiler/schedule.py
  @@ -65,7 +65,11 @@
           if backend is None:
               raise QiskitError("Must supply either a backend or InstructionScheduleMap for "
                                 "scheduling passes.")
  -        inst_map = backend.defaults().instruction_schedule_map
  +        defaults = backend.defaults()
  +        if defaults is None:
  +            raise QiskitError("The backend defaults are unavailable. The backend may not "
  +                              "support pulse.")
  +        inst_map = defaults.instruction_schedule_map
       if meas_map is None:
           if backend is None:
               raise QiskitError("Must supply either a backend or a meas_map for scheduling passes.")
  
verification_info: {"golden_diff": "diff --git a/qiskit/compiler/schedule.py b/qiskit/compiler/schedule.py\n--- a/qiskit/compiler/schedule.py\n+++ b/qiskit/compiler/schedule.py\n@@ -65,7 +65,11 @@\n         if backend is None:\n             raise QiskitError(\"Must supply either a backend or InstructionScheduleMap for \"\n                               \"scheduling passes.\")\n-        inst_map = backend.defaults().instruction_schedule_map\n+        defaults = backend.defaults()\n+        if defaults is None:\n+            raise QiskitError(\"The backend defaults are unavailable. The backend may not \"\n+                              \"support pulse.\")\n+        inst_map = defaults.instruction_schedule_map\n     if meas_map is None:\n         if backend is None:\n             raise QiskitError(\"Must supply either a backend or a meas_map for scheduling passes.\")\n", "issue": "circuit -> schedule raises exception\n<!-- \u26a0\ufe0f If you do not respect this template, your issue will be closed -->\r\n<!-- \u26a0\ufe0f Make sure to browse the opened and closed issues -->\r\n\r\n### Information\r\n\r\n- **Qiskit Terra version**: master\r\n- **Python version**:\r\n- **Operating system**:\r\n\r\n### What is the current behavior?\r\n```python\r\nghz = QuantumCircuit(5, 5)\r\nghz.h(0)\r\nghz.cx(range(4), range(1,5))\r\nghz.barrier()\r\nghz.measure(range(5), range(5))\r\n\r\nsch = schedule(ghz, backend)\r\n```\r\n\r\ngives:\r\n\r\nAttributeError: 'NoneType' object has no attribute 'instruction_schedule_map'\r\n\r\nThis works on older versions.\r\n\r\n\r\n### Steps to reproduce the problem\r\n\r\n\r\n\r\n### What is the expected behavior?\r\n\r\n\r\n\r\n### Suggested solutions\r\n\r\n\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# This code is part of Qiskit.\n#\n# (C) Copyright IBM 2019.\n#\n# This code is licensed under the Apache License, Version 2.0. You may\n# obtain a copy of this license in the LICENSE.txt file in the root directory\n# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Any modifications or derivative works of this code must retain this\n# copyright notice, and modified files need to carry a notice indicating\n# that they have been altered from the originals.\n\n\"\"\"\nConvenience entry point into pulse scheduling, requiring only a circuit and a backend. For more\ncontrol over pulse scheduling, look at `qiskit.scheduler.schedule_circuit`.\n\"\"\"\nimport logging\n\nfrom time import time\nfrom typing import List, Optional, Union\n\nfrom qiskit.circuit.quantumcircuit import QuantumCircuit\nfrom qiskit.exceptions import QiskitError\nfrom qiskit.pulse import InstructionScheduleMap, Schedule\nfrom qiskit.providers import BaseBackend\nfrom qiskit.scheduler import ScheduleConfig\nfrom qiskit.scheduler.schedule_circuit import schedule_circuit\n\nLOG = logging.getLogger(__name__)\n\n\ndef _log_schedule_time(start_time, end_time):\n    log_msg = \"Total Scheduling Time - %.5f (ms)\" % ((end_time - start_time) * 1000)\n    LOG.info(log_msg)\n\n\ndef schedule(circuits: Union[QuantumCircuit, List[QuantumCircuit]],\n             backend: Optional[BaseBackend] = None,\n             inst_map: Optional[InstructionScheduleMap] = None,\n             meas_map: Optional[List[List[int]]] = None,\n             method: Optional[Union[str, List[str]]] = None) -> Union[Schedule, List[Schedule]]:\n    \"\"\"\n    Schedule a circuit to a pulse ``Schedule``, using the backend, according to any specified\n    methods. Supported methods are documented in :py:mod:`qiskit.scheduler.schedule_circuit`.\n\n    Args:\n        circuits: The quantum circuit or circuits to translate\n        backend: A backend instance, which contains hardware-specific data required for scheduling\n        inst_map: Mapping of circuit operations to pulse schedules. If ``None``, defaults to the\n                  ``backend``\\'s ``instruction_schedule_map``\n        meas_map: List of sets of qubits that must be measured together. If ``None``, defaults to\n                  the ``backend``\\'s ``meas_map``\n        method: Optionally specify a particular scheduling method\n\n    Returns:\n        A pulse ``Schedule`` that implements the input circuit\n\n    Raises:\n        QiskitError: If ``inst_map`` and ``meas_map`` are not passed and ``backend`` is not passed\n    \"\"\"\n    start_time = time()\n    if inst_map is None:\n        if backend is None:\n            raise QiskitError(\"Must supply either a backend or InstructionScheduleMap for \"\n                              \"scheduling passes.\")\n        inst_map = backend.defaults().instruction_schedule_map\n    if meas_map is None:\n        if backend is None:\n            raise QiskitError(\"Must supply either a backend or a meas_map for scheduling passes.\")\n        meas_map = backend.configuration().meas_map\n\n    schedule_config = ScheduleConfig(inst_map=inst_map, meas_map=meas_map)\n    circuits = circuits if isinstance(circuits, list) else [circuits]\n    schedules = [schedule_circuit(circuit, schedule_config, method) for circuit in circuits]\n    end_time = time()\n    _log_schedule_time(start_time, end_time)\n    return schedules[0] if len(schedules) == 1 else schedules\n", "path": "qiskit/compiler/schedule.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# This code is part of Qiskit.\n#\n# (C) Copyright IBM 2019.\n#\n# This code is licensed under the Apache License, Version 2.0. You may\n# obtain a copy of this license in the LICENSE.txt file in the root directory\n# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Any modifications or derivative works of this code must retain this\n# copyright notice, and modified files need to carry a notice indicating\n# that they have been altered from the originals.\n\n\"\"\"\nConvenience entry point into pulse scheduling, requiring only a circuit and a backend. For more\ncontrol over pulse scheduling, look at `qiskit.scheduler.schedule_circuit`.\n\"\"\"\nimport logging\n\nfrom time import time\nfrom typing import List, Optional, Union\n\nfrom qiskit.circuit.quantumcircuit import QuantumCircuit\nfrom qiskit.exceptions import QiskitError\nfrom qiskit.pulse import InstructionScheduleMap, Schedule\nfrom qiskit.providers import BaseBackend\nfrom qiskit.scheduler import ScheduleConfig\nfrom qiskit.scheduler.schedule_circuit import schedule_circuit\n\nLOG = logging.getLogger(__name__)\n\n\ndef _log_schedule_time(start_time, end_time):\n    log_msg = \"Total Scheduling Time - %.5f (ms)\" % ((end_time - start_time) * 1000)\n    LOG.info(log_msg)\n\n\ndef schedule(circuits: Union[QuantumCircuit, List[QuantumCircuit]],\n             backend: Optional[BaseBackend] = None,\n             inst_map: Optional[InstructionScheduleMap] = None,\n             meas_map: Optional[List[List[int]]] = None,\n             method: Optional[Union[str, List[str]]] = None) -> Union[Schedule, List[Schedule]]:\n    \"\"\"\n    Schedule a circuit to a pulse ``Schedule``, using the backend, according to any specified\n    methods. Supported methods are documented in :py:mod:`qiskit.scheduler.schedule_circuit`.\n\n    Args:\n        circuits: The quantum circuit or circuits to translate\n        backend: A backend instance, which contains hardware-specific data required for scheduling\n        inst_map: Mapping of circuit operations to pulse schedules. If ``None``, defaults to the\n                  ``backend``\\'s ``instruction_schedule_map``\n        meas_map: List of sets of qubits that must be measured together. If ``None``, defaults to\n                  the ``backend``\\'s ``meas_map``\n        method: Optionally specify a particular scheduling method\n\n    Returns:\n        A pulse ``Schedule`` that implements the input circuit\n\n    Raises:\n        QiskitError: If ``inst_map`` and ``meas_map`` are not passed and ``backend`` is not passed\n    \"\"\"\n    start_time = time()\n    if inst_map is None:\n        if backend is None:\n            raise QiskitError(\"Must supply either a backend or InstructionScheduleMap for \"\n                              \"scheduling passes.\")\n        defaults = backend.defaults()\n        if defaults is None:\n            raise QiskitError(\"The backend defaults are unavailable. The backend may not \"\n                              \"support pulse.\")\n        inst_map = defaults.instruction_schedule_map\n    if meas_map is None:\n        if backend is None:\n            raise QiskitError(\"Must supply either a backend or a meas_map for scheduling passes.\")\n        meas_map = backend.configuration().meas_map\n\n    schedule_config = ScheduleConfig(inst_map=inst_map, meas_map=meas_map)\n    circuits = circuits if isinstance(circuits, list) else [circuits]\n    schedules = [schedule_circuit(circuit, schedule_config, method) for circuit in circuits]\n    end_time = time()\n    _log_schedule_time(start_time, end_time)\n    return schedules[0] if len(schedules) == 1 else schedules\n", "path": "qiskit/compiler/schedule.py"}]}