inducer / inducer/pycuda

pycuda.compiler.SourceModule incorrectly handles sources in `bytes` type

Open
#67 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.1k
Forks
298
Avg merge
4m
Merged PRs (30d)
1

Description

Cuda source code compilation fails if it's passed to `pycuda.compiler.SourceModule` as Python 3's `binary` (e.g. when source was read from filesystem in binary mode).

In [this](https://github.com/inducer/pycuda/blob/dbbb6fe9fa6dd0f225fc32193968eef7559398e8/pycuda/compiler.py#L190) code:

```
if not no_extern_c:
source = 'extern "C" {\n%s\n}\n' % source
```

`binary` is being implicitly converted to string with invalid cuda code, e.g.:

```
In [10]: source = b"Test"
In [11]: source = 'extern "C" {\n%s\n}\n' % source
In [12]: print(source)
extern "C" {
b'Test'
}
```

Notice the `b'Test'` in result source code.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.