Report error when processing folders on the command line
Closed this issue · 2 comments
wevsty commented
Describe the bug
Error when formatting a folder with multiple files using the command line
To Reproduce
For example:
Create a new folder src
and create 2 empty files in src
mkdir src
type nul > ./src/t1.py
type nul > ./src/t2.py
black ./src
The resulting error is:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\root\AppData\Local\pypoetry\Cache\virtualenvs\test-3OFd-K4v-py3.12\Scripts\black.exe\__main__.py", line 7, in <module>
File "src\black\__init__.py", line 1588, in patched_main
File "C:\Users\root\AppData\Local\pypoetry\Cache\virtualenvs\test-3OFd-K4v-py3.12\Lib\site-packages\click\core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\root\AppData\Local\pypoetry\Cache\virtualenvs\test-3OFd-K4v-py3.12\Lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\root\AppData\Local\pypoetry\Cache\virtualenvs\test-3OFd-K4v-py3.12\Lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\root\AppData\Local\pypoetry\Cache\virtualenvs\test-3OFd-K4v-py3.12\Lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\root\AppData\Local\pypoetry\Cache\virtualenvs\test-3OFd-K4v-py3.12\Lib\site-packages\click\decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "src\black\__init__.py", line 711, in main
File "C:\Users\root\AppData\Local\pypoetry\Cache\virtualenvs\test-3OFd-K4v-py3.12\Lib\site-packages\black\concurrency.py", line 98, in reformat_many
loop = asyncio.new_event_loop()
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\USER_PROGRAMS\python\Lib\asyncio\events.py", line 823, in new_event_loop
return get_event_loop_policy().new_event_loop()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\USER_PROGRAMS\python\Lib\asyncio\events.py", line 720, in new_event_loop
return self._loop_factory()
^^^^^^^^^^^^^^^^^^^^
File "C:\USER_PROGRAMS\python\Lib\asyncio\windows_events.py", line 316, in __init__
super().__init__(proactor)
File "C:\USER_PROGRAMS\python\Lib\asyncio\proactor_events.py", line 640, in __init__
self._make_self_pipe()
File "C:\USER_PROGRAMS\python\Lib\asyncio\proactor_events.py", line 787, in _make_self_pipe
self._ssock, self._csock = socket.socketpair()
^^^^^^^^^^^^^^^^^^^
File "C:\USER_PROGRAMS\python\Lib\socket.py", line 642, in _fallback_socketpair
raise ConnectionError("Unexpected peer connection")
ConnectionError: Unexpected peer connection
Exception ignored in: <function BaseEventLoop.__del__ at 0x0000000003B8B380>
Traceback (most recent call last):
File "C:\USER_PROGRAMS\python\Lib\asyncio\base_events.py", line 728, in __del__
File "C:\USER_PROGRAMS\python\Lib\asyncio\proactor_events.py", line 697, in close
File "C:\USER_PROGRAMS\python\Lib\asyncio\proactor_events.py", line 779, in _close_self_pipe
AttributeError: 'ProactorEventLoop' object has no attribute '_ssock'
Expected behavior
It should not report any errors.
Environment
- Black version: 24.10.0
- OS and Python version: Windows11 23H2/ Python 3.12.6
Additional context
JelleZijlstra commented
I can't reproduce this on MacOS; possibly an issue with your Python installation or network stack.
wevsty commented
I can't reproduce this on MacOS; possibly an issue with your Python installation or network stack.
After your tip I checked the network stack.
Eventually I found out that the software Proxifier
was the cause and if you close the Proxifier
program it will be back to normal.
As it is a software compatibility issue, this issues closed.