← index #8298Issue #257
Related · high · value 1.174
QUERY · ISSUE

urequests.get() error related to getaddrinfo

openby rafaelarocaopened 2022-02-13updated 2022-02-13

Hello:

I just compiled MicroPython for RPI Pico with WIZNET5k support as described here: https://github.com/Wiznet/RP2040-HAT-MicroPython

Ethernet connects and works.

However urequests gives this error:

request = urequests.get('http://bipes.net.br/test.txt')
Traceback (most recent call last):
File "<stdin>", line 14, in <module>
File "urequests.py", line 116, in get
File "urequests.py", line 55, in request
TypeError: function takes 2 positional arguments but 4 were given

I checked urequests.py and the implementation is:
ai = usocket.getaddrinfo(host, port, 0, usocket.SOCK_STREAM)

If I change this line to
ai = usocket.getaddrinfo(host, port)

The problem is solved and urequests.get() works!

However, I am uncertain if this would cause other boards/implementations problems.

Can this fix be applied to urequests.py, or it could break other network implementations?

thanks

CANDIDATE · ISSUE

ESP32 doesn't support full getaddrinfo() params

closedby dcontrisopened 2018-02-05updated 2019-06-17

After installing the new version of picoweb and uasyncio, I noticed an error when calling app.run(). The error occurs because uasyncio init.py file contains a call to socket.getaddrinfo() with 4 arguments, when socket requires only 2. The error causes app.run() to fail.

11 comments
pfalcon · 2018-02-05

I can't reproduce this.

dcontris · 2018-02-05

I noticed that usocket.getaddrinfo only takes 2 arguments, but uasyncio
init.py file passes 4. Do u have the wrong version of usocket? I
can't find one that use 4 arguments.

I can confirm removing the second two arguments in the initial file worked

On Feb 5, 2018 10:31 AM, "Paul Sokolovsky" notifications@github.com wrote:

I can't reproduce this.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/micropython/micropython-lib/issues/257#issuecomment-363176765,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQH_ll3V-D4kXmh4TT4Ys24TrzQE5Pncks5tR0kLgaJpZM4R4805
.

dcontris · 2018-02-05

Sorry, I meant to say "do I have the wrong version of usocket?"

On Feb 5, 2018 10:35 AM, "Dylan Contris" dcontris@gmail.com wrote:

I noticed that usocket.getaddrinfo only takes 2 arguments, but uasyncio
init.py file passes 4. Do u have the wrong version of usocket? I
can't find one that use 4 arguments.

I can confirm removing the second two arguments in the initial file worked

On Feb 5, 2018 10:31 AM, "Paul Sokolovsky" notifications@github.com
wrote:

I can't reproduce this.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/micropython/micropython-lib/issues/257#issuecomment-363176765,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQH_ll3V-D4kXmh4TT4Ys24TrzQE5Pncks5tR0kLgaJpZM4R4805
.

pfalcon · 2018-02-05

Sorry, I meant to say "do I have the wrong version of usocket?"

Possibly, you would need to tell what version of MicroPython on what hardware/OS you use.

dcontris · 2018-02-05

Micropython for ESP32 with the 2-5 version binaries

On Feb 5, 2018 10:38 AM, "Paul Sokolovsky" notifications@github.com wrote:

Sorry, I meant to say "do I have the wrong version of usocket?"

Possibly, you would need to tell what version of MicroPython on what
hardware/OS you use.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/micropython/micropython-lib/issues/257#issuecomment-363178709,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQH_luk5H51mgP2Fz0AvEGwwUZEqFW5Vks5tR0qfgaJpZM4R4805
.

pfalcon · 2018-02-05

Micropython for ESP32

See https://github.com/pfalcon/picoweb/issues/31

dcontris · 2018-02-05

Thanks!

On Feb 5, 2018 11:05 AM, "Paul Sokolovsky" notifications@github.com wrote:

Micropython for ESP32

See pfalcon/picoweb#31 https://github.com/pfalcon/picoweb/issues/31


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/micropython/micropython-lib/issues/257#issuecomment-363187690,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQH_lkANcQVlFTf1L7Maz55WiYjHQ0xbks5tR1DngaJpZM4R4805
.

Sunrise17 · 2018-02-13

I have faced with the same error while trying to run loop.create_task(asyncio.start_server(handle_client, ipAddress, 8080))
Is there some solution about it?

File "/lib/uasyncio/__init__.py", line 235, in start_server
TypeError: function takes 2 positional arguments but 4 were given
dpgeorge · 2018-02-21

This should now be fixed by https://github.com/micropython/micropython/commit/cced43feb8ffee0791f82c0358265329347f88c7

William04A · 2019-06-17

Same error with request = urequests.post(requesturl, headers={"User-Agent": "Python/SomeUserAgent"})
Function takes only 2 positional arguments but four were given...

Full MicroPython traceback:

Traceback (most recent call last):
  File "<stdin>", line 34, in <module>
  File "requests.py", line 115, in post
  File "requests.py", line 53, in request
TypeError: function takes 2 positional arguments but 4 were given

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied