Houdini 18.5 mangles with code or character encoding

   1114   0   0
User Avatar
Member
12 posts
Joined: Nov. 2021
Offline
Hey,

I'm on Houdini Apprentice 19 Python 3 and a friend who's a professional in the field running 18.5 Python 2.

While running a script, I created for him, which fetches data from a URL, the following error is thrown:

```
('\xf0\x9f\xa4\xa1 Oops! Failed to request the weather', InvalidSchema(u"No connection adapters were found for '2h2t2t2p2s2:2/2/2n2o2o2d2l2e2s2-2w2e2a2t2h2e2r2-2a2p2i2-292v2l2y222.2o2n2d2i2g2i2t2a2l2o2c2e2a2n2.2a2p2p2/2w2e2a2t2h2e2r2/2'",))
```

You might've not notice but if you ignore the `2`, it's an actually `https://foobar` address.

Here's where this originated from:

```
requests.get(apiUrl.replace('$id', str(currFrame))).json()
```

This does NOT happen if the URL is hard-typed. I have now changed this to use python formatter:

```
requests.get(apiUrl.format(str(currFrame))).json()
```

I should've done that at first, but I'm not a Python developer (I code in other languages, but Python is
quite simple to pickup and write).

I'll have to wait for his feedback on that, as I'm running Python 3 and he is on Python 2

My expectation is the `.format(...)` will solve the issue. Also, removed double quotes and used single quotes,
for wrapping strings

```
variableName="foobar"
```

Is now

```
variableName='foobar'
```

Thanks for reading!
  • Quick Links