internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: cocotb/cocotb

Issue:
Global DUT handle
Right now we supply a reference to the root `SimHandle` (aka the DUT object) as the sole argument to every test. There are some disadvantages to this, the biggest being the DUT object is not available from module-level code. I noticed this in https://github.com/cocotb/cocotb/pull/1502#discussion_r425582308, where information about the DUT is used at the module-level. I myself have had a need for this in the past, but simply worked around it.

Instead, I propose we make the DUT object globally available from the cocotb module: `cocotb.dut`. We now have access to the DUT object at the module-level. This is safe because the DUT cannot change from test to test. We could eventually stop supplying the DUT as an argument to the test functions, which aligns our tests better with other testing frameworks like pytest.

We would have to be careful because we could end up with module-level code modifying the DUT. We would want all tests in a module to run before loading the next module. That means we cannot pre-discover all functions to calculate the total test count. We could still do counts on a module level and have the summary print the total number of tests run. Or we could make the decision that we are not allowed to modify the DUT at the module-level, which can be enforced.


Discussion:
Note you can already do this with `simulator.get_root_handle`.

Resolving patch:
diff --git a/cocotb/__init__.py b/cocotb/__init__.py
--- a/cocotb/__init__.py
+++ b/cocotb/__init__.py
@@ -129,6 +129,16 @@ def _reopen_stream_with_buffering(stream_name):
 _library_coverage = None
 """ used for cocotb library coverage """
 
+top = None  # type: cocotb.handle.SimHandleBase
+r"""
+A handle to the :envvar:`TOPLEVEL` entity/module.
+
+This is equivalent to the :term:`DUT` parameter given to cocotb tests, so it can be used wherever that variable can be used.
+It is particularly useful for extracting information about the :term:`DUT` in module-level class and function definitions;
+and in parameters to :class:`.TestFactory`\ s.
+``None`` if :mod:`cocotb` was not loaded from a simulator.
+"""
+
 
 def fork(coro: Union[RunningTask, Coroutine]) -> RunningTask:
     """ Schedule a coroutine to be run concurrently. See :ref:`coroutines` for details on its use. """
@@ -239,11 +249,12 @@ def _initialise_testbench(argv_):
     if not handle:
         raise RuntimeError("Can not find root handle ({})".format(root_name))
 
-    dut = cocotb.handle.SimHandle(handle)
+    global top
+    top = cocotb.handle.SimHandle(handle)
 
     # start Regression Manager
     global regression_manager
-    regression_manager = RegressionManager.from_discovery(dut)
+    regression_manager = RegressionManager.from_discovery(top)
     regression_manager.execute()
 
     _rlock.release()


Test patch:
Repository: cocotb/cocotb

Issue:
Use setuptools_scm for generating a version number
[setuptools_scm](https://github.com/pypa/setuptools_scm/) can automatically generate version numbers based on git tags and versioning information. This will allow us to exactly identify which commit a user is reporting an issue with if it is not a released version. It will also remove one step of the release process.


Discussion:

Resolving patch:
diff --git a/cocotb/_version.py b/cocotb/_version.py
deleted file mode 100644
--- a/cocotb/_version.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# Package versioning solution originally found here:
-# http://stackoverflow.com/q/458550
-
-# Store the version here so:
-# 1) we don't load dependencies by storing it in __init__.py
-# 2) we can import it in setup.py for the same reason
-# 3) we can import it into your module
-__version__ = '1.5.0.dev0'
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -73,9 +73,6 @@ def package_files(directory):
     return paths
 
 
-# this sets the __version__ variable
-exec(read_file(path.join('cocotb', '_version.py')))
-
 # store log from build_libs and display at the end in verbose mode
 # see https://github.com/pypa/pip/issues/6634
 log_stream = StringIO()
@@ -87,7 +84,11 @@ def package_files(directory):
 setup(
     name='cocotb',
     cmdclass={'build_ext': build_ext},
-    version=__version__,  # noqa: F821
+    use_scm_version=dict(
+        write_to='cocotb/_version.py',
+        write_to_template='__version__ = {version!r}',
+        version_scheme='release-branch-semver'
+    ),
     description='cocotb is a coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python.',
     url='https://docs.cocotb.org',
     license='BSD',
@@ -96,6 +97,7 @@ def package_files(directory):
     author='Chris Higgs, Stuart Hodgson',
     maintainer='cocotb contributors',
     maintainer_email='cocotb@lists.librecores.org',
+    setup_requires=['setuptools_scm'],
     install_requires=[],
     python_requires='>=3.5',
     packages=find_packages(),


Test patch:
Repository: cocotb/cocotb

Issue:
cocotb.hook does not do anything unless in a module present in COCOTB_HOOKS
Marking a function with `@cocotb.hook` is insufficient for it to do anything - you also have to set the `COCOTB_HOOKS` environment variable to contain the module name where the decorated function resides.

Either we should document this, or we should just remove `cocotb.hook`. None of our tests test `cocotb.hook`. Is anyone using it?


Discussion:
The hooks functionality was added in https://github.com/potentialventures/cocotb/pull/565 by @stuarthodgson and @chiggs. So it's most likely used or has been used by them. There's a tiny bit of documentation at https://github.com/potentialventures/cocotb/blob/b6f24c142b14ade52a99e8c8c3d2fd46d49a9e77/cocotb/__init__.py#L113-L114.

@stuarthodgson @chiggs 
- Are you using cocotb.hook() at the moment and is it still useful to you?
- Can you outline a quick use case?
It is used by others are organisation so please don't go removing it. I'll try and dignup some documentation for it buts it's a bit esoteric.
Thanks @stuarthodgson. A use case would be nice to make sure we can add tests to ensure it doesn't get broken.
I'm backtracking on this. It can be killed with great predudice.

Resolving patch:
diff --git a/cocotb/decorators.py b/cocotb/decorators.py
--- a/cocotb/decorators.py
+++ b/cocotb/decorators.py
@@ -451,15 +451,27 @@ def decorator(f):
 
 @public
 class hook(coroutine, metaclass=_decorator_helper):
-    """Decorator to mark a function as a hook for cocotb.
+    r"""
+    Decorator to mark a function as a hook for cocotb.
 
     Used as ``@cocotb.hook()``.
 
     All hooks are run at the beginning of a cocotb test suite, prior to any
-    test code being run."""
+    test code being run.
+
+    .. deprecated:: 1.5
+        Hooks are deprecated.
+        Their functionality can be replaced with module-level Python code,
+        higher-priority tests using the ``stage`` argument to :func:`cocotb.test`\ s,
+        or custom decorators which perform work before and after the tests
+        they decorate.
+    """
 
     def __init__(self, f):
         super(hook, self).__init__(f)
+        warnings.warn(
+            "Hooks have been deprecated. See the documentation for suggestions on alternatives.",
+            DeprecationWarning, stacklevel=2)
         self.im_hook = True
         self.name = self._func.__name__
 


Test patch:
diff --git a/tests/test_cases/test_cocotb/test_deprecated.py b/tests/test_cases/test_cocotb/test_deprecated.py
--- a/tests/test_cases/test_cocotb/test_deprecated.py
+++ b/tests/test_cases/test_cocotb/test_deprecated.py
@@ -78,3 +78,11 @@ async def test_raise_error_deprecated(dut):
     with assert_deprecated():
         with assert_raises(cocotb.result.TestError):
             cocotb.result.raise_error(cocotb.triggers.Timer(1), "A test exception")
+
+
+@cocotb.test()
+async def test_hook_deprecated(_):
+    async def example():
+        pass
+    with assert_deprecated():
+        cocotb.hook()(example)
Repository: cocotb/cocotb

Issue:
Broken intersphinx link in docs
```
/home/kaleb/dev/cocotb/documentation/source/generated/master-notes.rst:53: WARNING: undefined label: python:library/exception (if the link has no caption the label must precede a section header)
```

I'm not entirely sure how to get this to link correctly. Alternatively, just remove it.


Discussion:

Resolving patch:
diff --git a/cocotb/clock.py b/cocotb/clock.py
--- a/cocotb/clock.py
+++ b/cocotb/clock.py
@@ -110,7 +110,7 @@ async def custom_clock():
     .. versionchanged:: 1.5
         Support ``'step'`` as the the *units* argument to mean "simulator time step".
 
-    .. deprecation:: 1.5
+    .. deprecated:: 1.5
         Using None as the the *units* argument is deprecated, use ``'step'`` instead.
     """
 
diff --git a/cocotb/decorators.py b/cocotb/decorators.py
--- a/cocotb/decorators.py
+++ b/cocotb/decorators.py
@@ -491,7 +491,7 @@ class test(coroutine, metaclass=_decorator_helper):
 
             .. versionadded:: 1.3
 
-            .. deprecation:: 1.5
+            .. deprecated:: 1.5
                 Using None as the the *timeout_unit* argument is deprecated, use ``'step'`` instead.
          expect_fail (bool, optional):
             Don't mark the result as a failure if the test fails.
diff --git a/cocotb/triggers.py b/cocotb/triggers.py
--- a/cocotb/triggers.py
+++ b/cocotb/triggers.py
@@ -206,7 +206,7 @@ def __init__(self, time_ps, units="step"):
         .. versionchanged:: 1.5
             Support ``'step'`` as the the *units* argument to mean "simulator time step".
 
-        .. deprecation:: 1.5
+        .. deprecated:: 1.5
             Using None as the the *units* argument is deprecated, use ``'step'`` instead.
         """
         GPITrigger.__init__(self)
@@ -899,7 +899,7 @@ async def with_timeout(trigger, timeout_time, timeout_unit="step"):
 
     .. versionadded:: 1.3
 
-    .. deprecation:: 1.5
+    .. deprecated:: 1.5
         Using None as the the *timeout_unit* argument is deprecated, use ``'step'`` instead.
    """
 


Test patch:
Repository: cocotb/cocotb

Issue:
Can ANSI avoid using BLUE_FG/BG? Save my eyes please.
The default color: (I've been putting up with this color for years.)
![Screenshot_2021-03-02_10-29-18](https://user-images.githubusercontent.com/4454365/109587715-84bd7980-7b42-11eb-9c4f-4b90c09b6f03.png)

After I changed the BLUE_xx in COLOR_INFO and COLOR_TEST in ANSI.py to BRIGHT_BLUE_xx and the result is much better:
![Screenshot_2021-03-02_10-29-41](https://user-images.githubusercontent.com/4454365/109587721-871fd380-7b42-11eb-97cf-c077cb131dbb.png)

By the way, thanks all the contributors of cocotb.


Discussion:

Resolving patch:
diff --git a/cocotb/ANSI.py b/cocotb/ANSI.py
--- a/cocotb/ANSI.py
+++ b/cocotb/ANSI.py
@@ -76,7 +76,6 @@
 
 COLOR_DEFAULT  = DEFAULT
 
-COLOR_INFO     = BLUE_FG
 COLOR_WARNING  = YELLOW_FG
 COLOR_ERROR    = RED_FG
 COLOR_CRITICAL = RED_BG + BLACK_FG
diff --git a/cocotb/log.py b/cocotb/log.py
--- a/cocotb/log.py
+++ b/cocotb/log.py
@@ -236,7 +236,7 @@ class SimColourLogFormatter(SimLogFormatter):
 
     loglevel2colour = {
         logging.DEBUG   :       "%s",
-        logging.INFO    :       ANSI.COLOR_INFO + "%s" + ANSI.COLOR_DEFAULT,
+        logging.INFO    :       "%s",
         logging.WARNING :       ANSI.COLOR_WARNING + "%s" + ANSI.COLOR_DEFAULT,
         logging.ERROR   :       ANSI.COLOR_ERROR + "%s" + ANSI.COLOR_DEFAULT,
         logging.CRITICAL:       ANSI.COLOR_CRITICAL + "%s" + ANSI.COLOR_DEFAULT,


Test patch:
Repository: cocotb/cocotb

Issue:
TOPLEVEL should be whitespace stripped
From here: https://github.com/cocotb/cocotb/blob/ecb43878a6af0605fdf08c2f1829cc401bfdeb36/cocotb/__init__.py#L219-L225

On Questa with the FLI, trailing whitespace causes the toplevel entity to not be found since it does a strict `!strcmp()`.


Discussion:

Resolving patch:
diff --git a/cocotb/__init__.py b/cocotb/__init__.py
--- a/cocotb/__init__.py
+++ b/cocotb/__init__.py
@@ -218,6 +218,7 @@ def _initialise_testbench_(argv_):
 
     root_name = os.getenv("TOPLEVEL")
     if root_name is not None:
+        root_name = root_name.strip()
         if root_name == "":
             root_name = None
         elif '.' in root_name:


Test patch:
Repository: cocotb/cocotb

Issue:
TestFactory: auto-generated test names are not applied
System: 
Cocotb 1.6.0 
Python 3.9
Linux 64bits

The removal of these lines in the RegressionManager method  '_create_test' in commit fc32b3bb27bf78dd885c833e581f51bfeb50900b

>     _my_test.__name__ = name
>     _my_test.__qualname__ = name
>     _my_test.__doc__ = documentation
>     _my_test.__module__ = mod.__name__

Results in the generated tests all sharing the name of the base test function, e.g.

> Found test module.parametrized_test
> Found test module.parametrized_test
> Found test module.parametrized_test
> Found test module.parametrized_test
> etc ...

Instead of being append an index name as expected

> Found test module.parametrized_test_001
> Found test module.parametrized_test_002
> Found test module.parametrized_test_003
> Found test module.parametrized_test_004
> etc ...

This also breaks the 'prefix' and 'postfix' parameters of the TestFactory


Discussion:

Resolving patch:
diff --git a/cocotb/regression.py b/cocotb/regression.py
--- a/cocotb/regression.py
+++ b/cocotb/regression.py
@@ -623,6 +623,11 @@ def _create_test(function, name, documentation, mod, *args, **kwargs):
     async def _my_test(dut):
         await function(dut, *args, **kwargs)
 
+    _my_test.__name__ = name
+    _my_test.__qualname__ = name
+    _my_test.__doc__ = documentation
+    _my_test.__module__ = mod.__name__
+
     return cocotb.test()(_my_test)
 
 


Test patch:
Repository: cocotb/cocotb

Issue:
factory ise when changing form 1.5.2 to 1.6.1
Hi I have just updated from 1.5.2 to 1.6.1 and Im getting a error from my run_test. I generate my tests using the TestFactory, this passes in the name of a function into the data_in input on run_test. But when I do `for transaction in data_in():` I get the error 
TypeError: 'NoneType' object is not callable
There must be a change in the use case between 1.5.2 and 1.6.1 but i cant find any documentation on it.


Discussion:
You are going to have to post a minimal failing example.
```
@cocotb.coroutine
def run_test(dut, data_in=None, idle_inserter=None, backpressure_inserter=None):

    cocotb.fork(Clock(dut.clk, 5000).start())
    tb = EthernetStripperTB(dut)

    if backpressure_inserter is not None:
        tb.backpressure.start(backpressure_inserter())

    yield tb.reset()
    dut.dout_ready = 1

    # Send in the packets
    for transaction in data_in():
        yield tb.input.send(raw(Ether()/transaction))

    yield Timer(1000000)
    yield RisingEdge(dut.clk)

    raise tb.scoreboard.result


def random_packet_sizes(min_size=64, max_size=1024, npackets=100):
    """random string data of a random length"""
    for i in range(npackets):
        yield get_bytes(random.randint(min_size, max_size), random_data())

factory = TestFactory(run_test)
factory.add_option("data_in", [random_packet_sizes])
factory.add_option("backpressure_inserter", [None, intermittent_single_cycles])
factory.generate_tests()

```
Looks like support for `@cocotb.coroutine` was accidentally broken. We missed this because we updated all the tests to use async/await.

Resolving patch:
diff --git a/cocotb/regression.py b/cocotb/regression.py
--- a/cocotb/regression.py
+++ b/cocotb/regression.py
@@ -35,7 +35,6 @@
 import traceback
 import pdb
 from typing import Any, Optional, Tuple, Iterable
-from functools import wraps
 
 import cocotb
 import cocotb.ANSI as ANSI
@@ -619,7 +618,6 @@ def _create_test(function, name, documentation, mod, *args, **kwargs):
         Decorated test function
     """
 
-    @wraps(function)
     async def _my_test(dut):
         await function(dut, *args, **kwargs)
 


Test patch:
diff --git a/tests/test_cases/test_cocotb/test_testfactory.py b/tests/test_cases/test_cocotb/test_testfactory.py
--- a/tests/test_cases/test_cocotb/test_testfactory.py
+++ b/tests/test_cases/test_cocotb/test_testfactory.py
@@ -10,6 +10,7 @@
 
 import cocotb
 from cocotb.regression import TestFactory
+from cocotb.triggers import NullTrigger
 
 
 testfactory_test_names = set()
@@ -63,3 +64,22 @@ def __await__(self):
 tf = TestFactory(TestClass)
 tf.add_option("myarg", [1])
 tf.generate_tests()
+
+
+generator_testfactory_args = set()
+
+
+@cocotb.coroutine
+def generator_test(dut, arg):
+    generator_testfactory_args.add(arg)
+    yield NullTrigger()
+
+
+generator_testfactory = TestFactory(generator_test)
+generator_testfactory.add_option("arg", [1, 2, 3, 4])
+generator_testfactory.generate_tests()
+
+
+@cocotb.test()
+async def test_generator_testfactory(_):
+    assert generator_testfactory_args == {1, 2, 3, 4}
Repository: cocotb/cocotb

Issue:
Update cached logging level in C when Python log level is changed
As an optimization gpi_log caches the gpi logging level. This cached value is not currently updated when the "cocotb.gpi" logger's level is updated in Python. This will require creating a `logging.Handler` subclass that calls `simulator.set_level` when its `setLevel` method is called.


Discussion:
Do you mean `logging.Logger`?

Resolving patch:
diff --git a/cocotb/log.py b/cocotb/log.py
--- a/cocotb/log.py
+++ b/cocotb/log.py
@@ -35,6 +35,7 @@
 import warnings
 
 import cocotb.ANSI as ANSI
+from cocotb import simulator
 from cocotb.utils import get_sim_time, get_time_from_sim_steps, want_color_output
 
 try:
@@ -109,8 +110,6 @@ def default_config():
 
     # Notify GPI of log level, which it uses as an optimization to avoid
     # calling into Python.
-    from cocotb import simulator
-
     simulator.log_level(log.getEffectiveLevel())
 
 
@@ -137,6 +136,11 @@ def colour(self):
         )
         return want_color_output()
 
+    def setLevel(self, level: int) -> None:
+        super().setLevel(level)
+        if self.name == "gpi":
+            simulator.log_level(level)
+
 
 # this used to be a class, hence the unusual capitalization
 def SimLog(name, ident=None):


Test patch:
diff --git a/tests/test_cases/test_cocotb/test_logging.py b/tests/test_cases/test_cocotb/test_logging.py
--- a/tests/test_cases/test_cocotb/test_logging.py
+++ b/tests/test_cases/test_cocotb/test_logging.py
@@ -78,6 +78,8 @@ async def test_logging_default_config(dut):
         os.environ = os_environ_prev
         cocotb_log.level = log_level_prev
 
+        logging.getLogger("gpi").setLevel(logging.INFO)
+
 
 @cocotb.test()
 async def test_custom_logging_levels(dut):
Repository: cocotb/cocotb

Issue:
Support `Logic` in sim handle value assignment
Currently there is support for `LogicArray`s, but not individual `Logic`s on 1-wide `ModifiableObject`s.


Discussion:

Resolving patch:
diff --git a/cocotb/handle.py b/cocotb/handle.py
--- a/cocotb/handle.py
+++ b/cocotb/handle.py
@@ -39,7 +39,7 @@
 from cocotb import simulator
 from cocotb.binary import BinaryRepresentation, BinaryValue
 from cocotb.log import SimLog
-from cocotb.types import LogicArray
+from cocotb.types import Logic, LogicArray
 
 # Only issue a warning for each deprecated attribute access
 _deprecation_warned = set()
@@ -867,8 +867,19 @@ def _set_value(self, value, call_sim):
             value = BinaryValue(value=num, n_bits=len(self), bigEndian=False)
 
         elif isinstance(value, LogicArray):
+            if len(self) != len(value):
+                raise ValueError(
+                    f"cannot assign value of length {len(value)} to handle of length {len(self)}"
+                )
             value = value.to_BinaryValue()
 
+        elif isinstance(value, Logic):
+            if len(self) != 1:
+                raise ValueError(
+                    f"cannot assign value of length 1 to handle of length {len(self)}"
+                )
+            value = BinaryValue(str(value))
+
         elif not isinstance(value, BinaryValue):
             raise TypeError(
                 "Unsupported type for value assignment: {} ({!r})".format(


Test patch:
diff --git a/tests/test_cases/test_cocotb/test_handle.py b/tests/test_cases/test_cocotb/test_handle.py
--- a/tests/test_cases/test_cocotb/test_handle.py
+++ b/tests/test_cases/test_cocotb/test_handle.py
@@ -12,7 +12,7 @@
 import cocotb
 from cocotb.handle import _Limits
 from cocotb.triggers import Timer
-from cocotb.types import LogicArray
+from cocotb.types import Logic, LogicArray
 
 SIM_NAME = cocotb.SIM_NAME.lower()
 
@@ -401,7 +401,18 @@ async def test_access_underscore_name(dut):
 
 
 @cocotb.test()
-async def assign_LogicArray(dut):
+async def test_assign_LogicArray(dut):
     value = LogicArray(dut.stream_in_data.value)
     value &= LogicArray("0x1X011z")
     dut.stream_in_data.value = value
+    with pytest.raises(ValueError):
+        dut.stream_in_data.value = LogicArray("010")  # not the correct size
+
+
+@cocotb.test()
+async def test_assign_Logic(dut):
+    dut.stream_in_ready.value = Logic("X")
+    await Timer(1, "ns")
+    assert dut.stream_in_ready.value.binstr.lower() == "x"
+    with pytest.raises(ValueError):
+        dut.stream_in_data.value = Logic("U")  # not the correct size
Repository: cocotb/cocotb

Issue:
RegressionManager total test changes as tests run
Starting in #2859 `RegressionManager.ntests` changes as the tests runs, so instead of printing the nth out of the total number of tests it prints the nth and remaining tests. 


Discussion:

Resolving patch:
diff --git a/cocotb/regression.py b/cocotb/regression.py
--- a/cocotb/regression.py
+++ b/cocotb/regression.py
@@ -131,18 +131,13 @@ def __init__(self, dut: SimHandle, tests: Iterable[Test]):
         for test in tests:
             self.log.info(f"Found test {test.__module__}.{test.__qualname__}")
             self._queue.append(test)
+        self.ntests = len(self._queue)
 
         if not self._queue:
             self.log.warning("No tests were discovered")
-            return
 
         self._queue.sort(key=lambda test: (test.stage, test._id))
 
-    @property
-    def ntests(self) -> int:
-        """Gets the number of tests in this regression."""
-        return len(self._queue)
-
     @classmethod
     def from_discovery(cls, dut: SimHandle):
         """


Test patch:
Repository: cocotb/cocotb

Issue:
Include logger name in log output
The culprit is logged, but the new "short" log format doesn't include the logger name so I don't get any useful information from this. IMO the default log format should include the logger name.
https://github.com/cocotb/cocotb/blob/c69454db92388a8915c99a35ca9cba06565fe4d5/cocotb/scheduler.py#L451


Discussion:
Agreement from the peanut gallery over here. I have to work around this.

Resolving patch:
diff --git a/cocotb/log.py b/cocotb/log.py
--- a/cocotb/log.py
+++ b/cocotb/log.py
@@ -44,11 +44,11 @@
     _suppress = 1
 
 # Column alignment
-_LEVEL_CHARS = len("CRITICAL")  # noqa
-_RECORD_CHARS = 35  # noqa
-_FILENAME_CHARS = 20  # noqa
-_LINENO_CHARS = 4  # noqa
-_FUNCNAME_CHARS = 31  # noqa
+_LEVEL_CHARS = len("CRITICAL")
+_RECORD_CHARS = 34
+_FILENAME_CHARS = 20
+_LINENO_CHARS = 4
+_FUNCNAME_CHARS = 31
 
 # Custom log level
 logging.TRACE = 5
@@ -210,11 +210,17 @@ def _format(self, level, record, msg, coloured=False):
         else:
             time_ns = get_time_from_sim_steps(sim_time, "ns")
             sim_time_str = f"{time_ns:6.2f}ns"
-        prefix = sim_time_str.rjust(11) + " " + level + " "
+        prefix = (
+            sim_time_str.rjust(11)
+            + " "
+            + level
+            + " "
+            + self.ljust(record.name, _RECORD_CHARS)
+            + " "
+        )
         if not _suppress:
             prefix += (
-                self.ljust(record.name, _RECORD_CHARS)
-                + self.rjust(os.path.split(record.filename)[1], _FILENAME_CHARS)
+                self.rjust(os.path.split(record.filename)[1], _FILENAME_CHARS)
                 + ":"
                 + self.ljust(str(record.lineno), _LINENO_CHARS)
                 + " in "


Test patch: