This file is indexed.

/usr/lib/python2.7/dist-packages/traits/py2to3.h is in python-traits 4.5.0-1ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
/*
    This header contains version specific implementations of certain
    often used tasks, behind a version agnostic API.
*/
#include "Python.h"


/* Attribute names
*/

#if PY_MAJOR_VERSION < 3
PyObject *Py2to3_NormaliseAttrName(PyObject *name) {

    if( PyString_Check(name) ){
        return name;
#ifdef Py_USING_UNICODE
    } else if ( PyUnicode_Check( name ) ) {
        return PyUnicode_AsEncodedString( name, NULL, NULL );
#endif // #ifdef Py_USING_UNICODE
    }
    return NULL;
}
void Py2to3_FinishNormaliseAttrName(PyObject *name,PyObject *nname){
    if(nname != name){
        Py_DECREF(nname);
    }
}
PyObject *Py2to3_AttrNameCStr(PyObject *name) {
    return name;
}
#define Py2to3_AttrName_AS_STRING(name) PyString_AS_STRING(name)
void Py2to3_FinishAttrNameCStr(PyObject *nname){
};
#else
PyObject *Py2to3_NormaliseAttrName(PyObject *name) {

    if( PyUnicode_Check(name) ){
        return name;
    }
    return NULL;
}
void Py2to3_FinishNormaliseAttrName(PyObject *name,PyObject *nname){
}
PyObject *Py2to3_AttrNameCStr(PyObject *name) {
    return PyUnicode_AsUTF8String(name);
}
#define Py2to3_AttrName_AS_STRING(name) PyBytes_AS_STRING(name)
void Py2to3_FinishAttrNameCStr(PyObject *nname){
    Py_DECREF(nname);
};
#endif


/*
    Simple strings for PyErr formatting:
    * Python 2:
      - Attributes are ASCII
      - PyErr_Format uses PyString_FromFormat
    * Python 3:
      - Attributes are Unicode
      - PyErr_Format uses PyUnicode_FromFormat

    Thus SimpleString == PyString if Python < 3 else PyUnicode
*/
#if PY_MAJOR_VERSION >= 3

#define Py2to3_SimpleString_Check(name) PyUnicode_Check(name)
#define Py2to3_SimpleString_GET_SIZE(name) PyUnicode_GET_SIZE(name)
#define Py2to3_SimpleString_Type PyUnicode_Type
#define Py2to3_PYERR_SIMPLE_STRING_FMTCHR "U"
#define Py2to3_PYERR_PREPARE_SIMPLE_STRING(name) name
#define Py2to3_SimpleString_FromString(string) PyUnicode_FromString(string)

#else

#define Py2to3_SimpleString_Check(name) PyString_Check(name)
#define Py2to3_SimpleString_GET_SIZE(name) PyString_GET_SIZE(name)
#define Py2to3_SimpleString_Type PyString_Type
#define Py2to3_PYERR_SIMPLE_STRING_FMTCHR "s"
#define Py2to3_PYERR_PREPARE_SIMPLE_STRING(name) PyString_AS_STRING(name)
#define Py2to3_SimpleString_FromString(string) PyString_FromString(string)

#endif


/* The following macro is defined from Python 2.6 and differently in Python 3 */
#ifndef Py_TYPE
    #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#endif


/* In Python 3, all ints are longs */
#if PY_MAJOR_VERSION >= 3
    #define Py2to3_PyNum_Check PyLong_Check
    #define Py2to3_PyNum_FromLong PyLong_FromLong
    #define Py2to3_PyNum_AsLong PyLong_AsLong
#else
    #define Py2to3_PyNum_Check PyInt_Check
    #define Py2to3_PyNum_FromLong PyInt_FromLong
    #define Py2to3_PyNum_AsLong PyInt_AsLong
#endif

/* Get hash of an object, using cached value for attribute names

 */
#ifndef Py_hash_t
    #define Py_hash_t long
#endif

#if PY_MAJOR_VERSION < 3
long Py2to3_GetHash_wCache(PyObject *obj){
    long hash;

    if ( PyString_CheckExact( obj ) &&
     ((hash = ((PyStringObject *) obj)->ob_shash) != -1) ) {
        return hash;
    }
    return PyObject_Hash( obj );
}
#else
Py_hash_t Py2to3_GetHash_wCache(PyObject *obj){
#ifndef Py_LIMITED_API
    Py_hash_t hash = -1;
    if ( PyUnicode_CheckExact( obj ) ) {
#if PY_MAJOR_VERSION < 3 || PY_MINOR_VERSION < 3
        hash = ((PyUnicodeObject *) obj)->hash;
#else
        hash = ((PyUnicodeObject *) obj)->_base._base.hash;
#endif
//    } else if ( PyBytes_CheckExact( key )) {
//        hash = ((PyBytesObject *) key)->ob_shash;
    }
    if (hash == -1) {
        hash = PyObject_Hash( obj );
    }
    return hash;
#else
    return PyObject_Hash( obj );
#endif // #ifndef Py_LIMITED_API
}
#endif // #if PY_MAJOR_VERION < 3


/* Get a value from a dict whose keys are attribute names.

  If *name* is of a type unfitting for an attribute name,
  *bad_attr* is returned.

  Does use the hash cache where possible.

  Precondition: *dict* is a valid PyDictObject
 */
#if PY_MAJOR_VERSION < 3

#ifdef Py_USING_UNICODE
#define Py2to3_AttrNameCheck(name) (PyString_Check(name) || PyUnicode_Check(name))
#else
#define Py2to3_AttrNameCheck(name) (PyString_Check(name))
#endif

PyObject *Py2to3_GetAttrDictValue(PyDictObject * dict, PyObject *name, PyObject *bad_attr) {

    long hash;
    PyObject *nname;
    PyObject *value;
    if ( PyString_CheckExact( name ) ) {
        if ( (hash = ((PyStringObject *) name)->ob_shash) == -1 )
           hash = PyObject_Hash( name );
        return (dict->ma_lookup)( dict, name, hash )->me_value;
    }

    nname = Py2to3_NormaliseAttrName(name);
    if( nname == NULL ){
        PyErr_Clear();
        return bad_attr;
    }

    hash = PyObject_Hash( nname );
    if( hash == -1 ){
        Py2to3_FinishNormaliseAttrName(name,nname);
        PyErr_Clear();
        return NULL;
    }
    value = (dict->ma_lookup)( dict, nname, hash )->me_value;
    Py2to3_FinishNormaliseAttrName(name,nname);
    return value;
}

#else // #if PY_MAJOR_VERSION < 3

#define Py2to3_AttrNameCheck(name) (PyUnicode_Check(name))

PyObject *Py2to3_GetAttrDictValue(PyDictObject * dict, PyObject *name, PyObject *bad_attr) {
#if !defined(Py_LIMITED_API) && (PY_MAJOR_VERSION < 3 || PY_MINOR_VERSION < 3) && 0 // this does not work as intended! don't use it!
    Py_hash_t hash;
    if( PyUnicode_CheckExact( name ) ) {
#if PY_MINOR_VERSION < 3
        hash = ((PyUnicodeObject *) dict)->hash;
#else
        // currently not usable, as dict->ma_lookup does not exist either
        hash = ((PyUnicodeObject *) dict)->_base._base.hash;
#endif
        if( hash == -1)
           hash = PyObject_Hash( name );
        return (dict->ma_lookup)( dict, name, hash )->me_value;
    }
#endif // #ifndef Py_LIMITED_API
    if( !PyUnicode_Check(name) )
        return bad_attr;

    return PyDict_GetItem((PyObject *)dict, name);
}

#endif // #if PY_MAJOR_VERSION < 3


/*
*/

double Py2to3_PyNum_AsDouble(PyObject *value) {
#if PY_MAJOR_VERSION < 3
    if ( PyInt_Check( value ) ) {
        return (double) PyInt_AS_LONG( value );
    } else if( !PyLong_Check(value) ){
#else
    if ( !PyLong_Check( value ) ) {
#endif  // #if PY_MAJOR_VERSION < 3
        PyErr_SetNone( PyExc_TypeError );
        return -1.;
    }
    return PyLong_AsDouble( value );
}


#ifndef PyVarObject_HEAD_INIT
    #define PyVarObject_HEAD_INIT(type, size) \
        PyObject_HEAD_INIT(type) size,
#endif



#if PY_MAJOR_VERSION >= 3
  #define Py2to3_MOD_ERROR_VAL NULL
  #define Py2to3_MOD_SUCCESS_VAL(val) val
  #define Py2to3_MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
  #define Py2to3_MOD_DEF(ob, name, doc, methods) \
          static struct PyModuleDef moduledef = { \
            PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \
          ob = PyModule_Create(&moduledef);
#else
  #define Py2to3_MOD_ERROR_VAL
  #define Py2to3_MOD_SUCCESS_VAL(val)
  #define Py2to3_MOD_INIT(name) void init##name(void)
  #define Py2to3_MOD_DEF(ob, name, doc, methods) \
          ob = Py_InitModule3(name, methods, doc);
#endif