4
4
5
5
#if PY_MAJOR_VERSION >= 3
6
6
#define PySass_IF_PY3 (three, two ) (three)
7
- #define PySass_Int_FromLong (v ) PyLong_FromLong(v)
8
- #define PySass_Bytes_Check (o ) PyBytes_Check(o)
9
- #define PySass_Bytes_GET_SIZE (o ) PyBytes_GET_SIZE(o)
10
- #define PySass_Bytes_AS_STRING (o ) PyBytes_AS_STRING(o)
11
7
#define PySass_Object_Bytes (o ) PyUnicode_AsUTF8String(PyObject_Str(o))
12
8
#else
13
9
#define PySass_IF_PY3 (three, two ) (two)
14
- #define PySass_Int_FromLong (v ) PyInt_FromLong(v)
15
- #define PySass_Bytes_Check (o ) PyString_Check(o)
16
- #define PySass_Bytes_GET_SIZE (o ) PyString_GET_SIZE(o)
17
- #define PySass_Bytes_AS_STRING (o ) PyString_AS_STRING(o)
18
10
#define PySass_Object_Bytes (o ) PyObject_Str(o)
19
11
#endif
20
12
@@ -211,7 +203,7 @@ static union Sass_Value* _number_to_sass_value(PyObject* value) {
211
203
PyObject* unit = PyObject_GetAttrString (value, " unit" );
212
204
PyObject* bytes = PyUnicode_AsEncodedString (unit, " UTF-8" , " strict" );
213
205
retv = sass_make_number (
214
- PyFloat_AsDouble (d_value), PySass_Bytes_AS_STRING (bytes)
206
+ PyFloat_AsDouble (d_value), PyBytes_AS_STRING (bytes)
215
207
);
216
208
Py_DECREF (d_value);
217
209
Py_DECREF (unit);
@@ -222,7 +214,7 @@ static union Sass_Value* _number_to_sass_value(PyObject* value) {
222
214
static union Sass_Value* _unicode_to_sass_value (PyObject* value) {
223
215
union Sass_Value* retv = NULL ;
224
216
PyObject* bytes = PyUnicode_AsEncodedString (value, " UTF-8" , " strict" );
225
- retv = sass_make_string (PySass_Bytes_AS_STRING (bytes));
217
+ retv = sass_make_string (PyBytes_AS_STRING (bytes));
226
218
Py_DECREF (bytes);
227
219
return retv;
228
220
}
@@ -231,7 +223,7 @@ static union Sass_Value* _warning_to_sass_value(PyObject* value) {
231
223
union Sass_Value* retv = NULL ;
232
224
PyObject* msg = PyObject_GetAttrString (value, " msg" );
233
225
PyObject* bytes = PyUnicode_AsEncodedString (msg, " UTF-8" , " strict" );
234
- retv = sass_make_warning (PySass_Bytes_AS_STRING (bytes));
226
+ retv = sass_make_warning (PyBytes_AS_STRING (bytes));
235
227
Py_DECREF (msg);
236
228
Py_DECREF (bytes);
237
229
return retv;
@@ -241,7 +233,7 @@ static union Sass_Value* _error_to_sass_value(PyObject* value) {
241
233
union Sass_Value* retv = NULL ;
242
234
PyObject* msg = PyObject_GetAttrString (value, " msg" );
243
235
PyObject* bytes = PyUnicode_AsEncodedString (msg, " UTF-8" , " strict" );
244
- retv = sass_make_error (PySass_Bytes_AS_STRING (bytes));
236
+ retv = sass_make_error (PyBytes_AS_STRING (bytes));
245
237
Py_DECREF (msg);
246
238
Py_DECREF (bytes);
247
239
return retv;
@@ -270,7 +262,7 @@ static union Sass_Value* _unknown_type_to_sass_error(PyObject* value) {
270
262
format_meth, type_name, NULL
271
263
);
272
264
PyObject* bytes = PyUnicode_AsEncodedString (result, " UTF-8" , " strict" );
273
- retv = sass_make_error (PySass_Bytes_AS_STRING (bytes));
265
+ retv = sass_make_error (PyBytes_AS_STRING (bytes));
274
266
Py_DECREF (type);
275
267
Py_DECREF (type_name);
276
268
Py_DECREF (fmt);
@@ -309,7 +301,7 @@ static PyObject* _exception_to_bytes() {
309
301
310
302
static union Sass_Value* _exception_to_sass_error () {
311
303
PyObject* bytes = _exception_to_bytes ();
312
- union Sass_Value* retv = sass_make_error (PySass_Bytes_AS_STRING (bytes));
304
+ union Sass_Value* retv = sass_make_error (PyBytes_AS_STRING (bytes));
313
305
Py_DECREF (bytes);
314
306
return retv;
315
307
}
@@ -318,7 +310,7 @@ static Sass_Import_List _exception_to_sass_import_error(const char* path) {
318
310
PyObject* bytes = _exception_to_bytes ();
319
311
Sass_Import_List import_list = sass_make_import_list (1 );
320
312
import_list[0 ] = sass_make_import_entry (path, 0 , 0 );
321
- sass_import_set_error (import_list[0 ], PySass_Bytes_AS_STRING (bytes), 0 , 0 );
313
+ sass_import_set_error (import_list[0 ], PyBytes_AS_STRING (bytes), 0 , 0 );
322
314
Py_DECREF (bytes);
323
315
return import_list;
324
316
}
@@ -340,8 +332,8 @@ static union Sass_Value* _to_sass_value(PyObject* value) {
340
332
retv = sass_make_boolean (value == Py_True);
341
333
} else if (PyUnicode_Check (value)) {
342
334
retv = _unicode_to_sass_value (value);
343
- } else if (PySass_Bytes_Check (value)) {
344
- retv = sass_make_string (PySass_Bytes_AS_STRING (value));
335
+ } else if (PyBytes_Check (value)) {
336
+ retv = sass_make_string (PyBytes_AS_STRING (value));
345
337
/* XXX: PyMapping_Check returns true for lists and tuples in python3 :( */
346
338
/* XXX: pypy derps on dicts: https://bitbucket.org/pypy/pypy/issue/1970 */
347
339
} else if (PyDict_Check (value) || PyObject_IsInstance (value, mapping_t )) {
@@ -415,7 +407,7 @@ static void _add_custom_functions(
415
407
PyObject* sass_function = PyList_GET_ITEM (custom_functions, i);
416
408
PyObject* signature = PySass_Object_Bytes (sass_function);
417
409
Sass_Function_Entry fn = sass_make_function (
418
- PySass_Bytes_AS_STRING (signature),
410
+ PyBytes_AS_STRING (signature),
419
411
_call_py_f,
420
412
sass_function
421
413
);
@@ -583,13 +575,13 @@ PySass_compile_filename(PyObject *self, PyObject *args) {
583
575
context = sass_make_file_context (filename);
584
576
options = sass_file_context_get_options (context);
585
577
586
- if (PySass_Bytes_Check (source_map_filename)) {
587
- size_t source_map_file_len = PySass_Bytes_GET_SIZE (source_map_filename);
578
+ if (PyBytes_Check (source_map_filename)) {
579
+ size_t source_map_file_len = PyBytes_GET_SIZE (source_map_filename);
588
580
if (source_map_file_len) {
589
581
char *source_map_file = (char *) malloc (source_map_file_len + 1 );
590
582
strncpy (
591
583
source_map_file,
592
- PySass_Bytes_AS_STRING (source_map_filename),
584
+ PyBytes_AS_STRING (source_map_filename),
593
585
source_map_file_len + 1
594
586
);
595
587
sass_option_set_source_map_file (options, source_map_file);
@@ -630,10 +622,10 @@ static char PySass_doc[] = "The thin binding of libsass for Python.";
630
622
631
623
PyObject* PySass_make_enum_dict () {
632
624
PyObject* dct = PyDict_New ();
633
- PyDict_SetItemString (dct, " nested" , PySass_Int_FromLong (SASS_STYLE_NESTED));
634
- PyDict_SetItemString (dct, " expanded" , PySass_Int_FromLong (SASS_STYLE_EXPANDED));
635
- PyDict_SetItemString (dct, " compact" , PySass_Int_FromLong (SASS_STYLE_COMPACT));
636
- PyDict_SetItemString (dct, " compressed" , PySass_Int_FromLong (SASS_STYLE_COMPRESSED));
625
+ PyDict_SetItemString (dct, " nested" , PyLong_FromLong (SASS_STYLE_NESTED));
626
+ PyDict_SetItemString (dct, " expanded" , PyLong_FromLong (SASS_STYLE_EXPANDED));
627
+ PyDict_SetItemString (dct, " compact" , PyLong_FromLong (SASS_STYLE_COMPACT));
628
+ PyDict_SetItemString (dct, " compressed" , PyLong_FromLong (SASS_STYLE_COMPRESSED));
637
629
return dct;
638
630
}
639
631
0 commit comments