44
55#if PY_MAJOR_VERSION >= 3
66#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)
117#define PySass_Object_Bytes (o ) PyUnicode_AsUTF8String(PyObject_Str(o))
128#else
139#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)
1810#define PySass_Object_Bytes (o ) PyObject_Str(o)
1911#endif
2012
@@ -211,7 +203,7 @@ static union Sass_Value* _number_to_sass_value(PyObject* value) {
211203 PyObject* unit = PyObject_GetAttrString (value, " unit" );
212204 PyObject* bytes = PyUnicode_AsEncodedString (unit, " UTF-8" , " strict" );
213205 retv = sass_make_number (
214- PyFloat_AsDouble (d_value), PySass_Bytes_AS_STRING (bytes)
206+ PyFloat_AsDouble (d_value), PyBytes_AS_STRING (bytes)
215207 );
216208 Py_DECREF (d_value);
217209 Py_DECREF (unit);
@@ -222,7 +214,7 @@ static union Sass_Value* _number_to_sass_value(PyObject* value) {
222214static union Sass_Value* _unicode_to_sass_value (PyObject* value) {
223215 union Sass_Value* retv = NULL ;
224216 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));
226218 Py_DECREF (bytes);
227219 return retv;
228220}
@@ -231,7 +223,7 @@ static union Sass_Value* _warning_to_sass_value(PyObject* value) {
231223 union Sass_Value* retv = NULL ;
232224 PyObject* msg = PyObject_GetAttrString (value, " msg" );
233225 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));
235227 Py_DECREF (msg);
236228 Py_DECREF (bytes);
237229 return retv;
@@ -241,7 +233,7 @@ static union Sass_Value* _error_to_sass_value(PyObject* value) {
241233 union Sass_Value* retv = NULL ;
242234 PyObject* msg = PyObject_GetAttrString (value, " msg" );
243235 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));
245237 Py_DECREF (msg);
246238 Py_DECREF (bytes);
247239 return retv;
@@ -270,7 +262,7 @@ static union Sass_Value* _unknown_type_to_sass_error(PyObject* value) {
270262 format_meth, type_name, NULL
271263 );
272264 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));
274266 Py_DECREF (type);
275267 Py_DECREF (type_name);
276268 Py_DECREF (fmt);
@@ -309,7 +301,7 @@ static PyObject* _exception_to_bytes() {
309301
310302static union Sass_Value* _exception_to_sass_error () {
311303 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));
313305 Py_DECREF (bytes);
314306 return retv;
315307}
@@ -318,7 +310,7 @@ static Sass_Import_List _exception_to_sass_import_error(const char* path) {
318310 PyObject* bytes = _exception_to_bytes ();
319311 Sass_Import_List import_list = sass_make_import_list (1 );
320312 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 );
322314 Py_DECREF (bytes);
323315 return import_list;
324316}
@@ -340,8 +332,8 @@ static union Sass_Value* _to_sass_value(PyObject* value) {
340332 retv = sass_make_boolean (value == Py_True);
341333 } else if (PyUnicode_Check (value)) {
342334 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));
345337 /* XXX: PyMapping_Check returns true for lists and tuples in python3 :( */
346338 /* XXX: pypy derps on dicts: https://bitbucket.org/pypy/pypy/issue/1970 */
347339 } else if (PyDict_Check (value) || PyObject_IsInstance (value, mapping_t )) {
@@ -415,7 +407,7 @@ static void _add_custom_functions(
415407 PyObject* sass_function = PyList_GET_ITEM (custom_functions, i);
416408 PyObject* signature = PySass_Object_Bytes (sass_function);
417409 Sass_Function_Entry fn = sass_make_function (
418- PySass_Bytes_AS_STRING (signature),
410+ PyBytes_AS_STRING (signature),
419411 _call_py_f,
420412 sass_function
421413 );
@@ -583,13 +575,13 @@ PySass_compile_filename(PyObject *self, PyObject *args) {
583575 context = sass_make_file_context (filename);
584576 options = sass_file_context_get_options (context);
585577
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);
588580 if (source_map_file_len) {
589581 char *source_map_file = (char *) malloc (source_map_file_len + 1 );
590582 strncpy (
591583 source_map_file,
592- PySass_Bytes_AS_STRING (source_map_filename),
584+ PyBytes_AS_STRING (source_map_filename),
593585 source_map_file_len + 1
594586 );
595587 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.";
630622
631623PyObject* PySass_make_enum_dict () {
632624 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));
637629 return dct;
638630}
639631
0 commit comments