Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid mode: 'rU' while trying to fdopen (porting to Python 3.11) #58

Open
k-neo opened this issue Jan 26, 2023 · 3 comments
Open

Invalid mode: 'rU' while trying to fdopen (porting to Python 3.11) #58

k-neo opened this issue Jan 26, 2023 · 3 comments

Comments

@k-neo
Copy link

k-neo commented Jan 26, 2023

The U file mode was removed in Python 3.11 because it had no effect so the U can merely be removed.

open(), io.open(), codecs.open() and fileinput.FileInput no longer accept 'U' (“universal newline”) in the file mode. In Python 3, “universal newline” mode is used by default whenever a file is opened in text mode, and the 'U' flag has been deprecated since Python 3.3. The newline parameter to these functions controls how universal newlines work. (Contributed by Victor Stinner in bpo-37330.)

Execution log

$ python3 main.py 
Traceback (most recent call last):
  File "/home/pi/Dev/peripheral/main.py", line 99, in <module>
    bleno = Bleno()
            ^^^^^^^
  File "/home/pi/.pyenv/versions/3.11.1/lib/python3.11/site-packages/pybleno/hci_socket/Emit.py", line 39, in new_init
    old_init(self, *k, **kw)
  File "/home/pi/.pyenv/versions/3.11.1/lib/python3.11/site-packages/pybleno/Bleno.py", line 41, in __init__
    self._bindings = BlenoBindings()
                     ^^^^^^^^^^^^^^^
  File "/home/pi/.pyenv/versions/3.11.1/lib/python3.11/site-packages/pybleno/hci_socket/Emit.py", line 39, in new_init
    old_init(self, *k, **kw)
  File "/home/pi/.pyenv/versions/3.11.1/lib/python3.11/site-packages/pybleno/hci_socket/Bindings.py", line 16, in __init__
    self._hci = Hci()
                ^^^^^
  File "/home/pi/.pyenv/versions/3.11.1/lib/python3.11/site-packages/pybleno/hci_socket/Emit.py", line 39, in new_init
    old_init(self, *k, **kw)
  File "/home/pi/.pyenv/versions/3.11.1/lib/python3.11/site-packages/pybleno/hci_socket/Hci.py", line 20, in __init__
    self._socket = BluetoothHCI(auto_start=False)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/.pyenv/versions/3.11.1/lib/python3.11/site-packages/pybleno/hci_socket/BluetoothHCI/BluetoothHCI.py", line 239, in __init__
    self.hci = BluetoothHCISocketProvider(device_id)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/.pyenv/versions/3.11.1/lib/python3.11/site-packages/pybleno/hci_socket/BluetoothHCI/BluetoothHCI.py", line 69, in __init__
    self._r = os.fdopen(self.__r, 'rU')
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen os>", line 1031, in fdopen
ValueError: invalid mode: 'rU'
@RoyBellingan
Copy link

Yes tried just now and is working fine with this fix.

@benjaminwp18
Copy link

benjaminwp18 commented Jul 22, 2024

@Adam-Langley Are there any plans to release a version with this fix to pip? I know there haven't been any other changes recently, but it would be great if the PyPi release of this package worked on 3.11.

@bodiroga
Copy link

bodiroga commented Aug 19, 2024

@Adam-Langley Are there any plans to release a version with this fix to pip? I know there haven't been any other changes recently, but it would be great if the PyPi release of this package worked on 3.11.

+1 (Thank you very much, @Adam-Langley, for all the work you have done!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants