HL-HDF
pyhlcompat.c File Reference

utilities that are helpful for the transition to python 3 More...

#include "pyhlcompat.h"

Functions

int PyHlhdfAPI_CompareWithASCIIString (PyObject *ptr, const char *name)
 Tests if a python object string (or unicode) is equal to name.
 
PyObject * PyHlhdf_StringOrUnicode_FromASCII (const char *buffer, Py_ssize_t size)
 Tries to get same behaviour for the result returned when getting a string from the data node.
 

Detailed Description

utilities that are helpful for the transition to python 3

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2017-02-23

Function Documentation

◆ PyHlhdf_StringOrUnicode_FromASCII()

PyObject * PyHlhdf_StringOrUnicode_FromASCII ( const char * buffer,
Py_ssize_t size )

Tries to get same behaviour for the result returned when getting a string from the data node.

For 2.7 PyString_FromStringAndSize is used, for 3.x a variant of _PyUnicode_FromASCII.

◆ PyHlhdfAPI_CompareWithASCIIString()

int PyHlhdfAPI_CompareWithASCIIString ( PyObject * ptr,
const char * name )

Tests if a python object string (or unicode) is equal to name.

Parameters
[in]ptr- the python string or unicode
[in]name- the string to compare with
Returns
0, -1 or 1