Merge lp:~ubuntu-branches/ubuntu/utopic/python-pyscss/utopic-201410021331 into lp:ubuntu/utopic/python-pyscss

Proposed by Ubuntu Package Importer
Status: Needs review
Proposed branch: lp:~ubuntu-branches/ubuntu/utopic/python-pyscss/utopic-201410021331
Merge into: lp:ubuntu/utopic/python-pyscss
Diff against target: 905 lines (+18/-726)
6 files modified
.pc/applied-patches (+0/-2)
.pc/fixed-non-ascii-in-README.rst.patch/README.rst (+0/-55)
.pc/python3-fixup.patch/scss/src/_speedups.c (+0/-554)
README.rst (+1/-1)
scss/src/_speedups.c (+17/-85)
scss/src/py3defs.h (+0/-29)
To merge this branch: bzr merge lp:~ubuntu-branches/ubuntu/utopic/python-pyscss/utopic-201410021331
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+236878@code.launchpad.net

Description of the change

The package importer has detected a possible inconsistency between the package history in the archive and the history in bzr. As the archive is authoritative the importer has made lp:ubuntu/utopic/python-pyscss reflect what is in the archive and the old bzr branch has been pushed to lp:~ubuntu-branches/ubuntu/utopic/python-pyscss/utopic-201410021331. This merge proposal was created so that an Ubuntu developer can review the situations and perform a merge/upload if necessary. There are three typical cases where this can happen.
  1. Where someone pushes a change to bzr and someone else uploads the package without that change. This is the reason that this check is done by the importer. If this appears to be the case then a merge/upload should be done if the changes that were in bzr are still desirable.
  2. The importer incorrectly detected the above situation when someone made a change in bzr and then uploaded it.
  3. The importer incorrectly detected the above situation when someone just uploaded a package and didn't touch bzr.

If this case doesn't appear to be the first situation then set the status of the merge proposal to "Rejected" and help avoid the problem in future by filing a bug at https://bugs.launchpad.net/udd linking to this merge proposal.

(this is an automatically generated message)

To post a comment you must log in.

Unmerged revisions

8. By Chuck Short

* d/python-pyscss.postrm: Removed due to Lintian error, and
  python-pyscss.prerm already removes the alternative.
* d/python3-pyscss.postrm: Removed due to Lintian error, and
  python3-pyscss.prerm already removes the alternative.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed file '.pc/applied-patches'
--- .pc/applied-patches 2014-09-24 21:54:24 +0000
+++ .pc/applied-patches 1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
1python3-fixup.patch
2fixed-non-ascii-in-README.rst.patch
30
=== removed directory '.pc/fixed-non-ascii-in-README.rst.patch'
=== removed file '.pc/fixed-non-ascii-in-README.rst.patch/README.rst'
--- .pc/fixed-non-ascii-in-README.rst.patch/README.rst 2014-06-28 06:51:52 +0000
+++ .pc/fixed-non-ascii-in-README.rst.patch/README.rst 1970-01-01 00:00:00 +0000
@@ -1,55 +0,0 @@
1pyScss, a Scss compiler for Python
2==================================
3
4pyScss is a compiler for SCSS flavor of the Sass language, a superset of CSS3
5that adds programming capabilities and some other syntactic sugar.
6
7Quickstart
8----------
9
10You need Python 2.6 or later. Python 3 is also supported.
11
12Installation::
13
14 pip install pyScss
15
16Usage::
17
18 python -mscss < style.scss
19
20Python API::
21
22 from scss import Scss
23 compiler = Scss()
24 compiler.compile("a { color: red + green; }")
25
26
27Features
28--------
29
3095% of Sass 3.2 is supported. If it's not supported, it's a bug! Please file
31a ticket.
32
33Most of Compass 0.11 is also built in.
34
35
36Further reading
37---------------
38
39Documentation is in Sphinx. You can build it yourself by running ``make html``
40from within the ``docs`` directory, or read it on RTD:
41http://pyscss.readthedocs.org/en/latest/
42
43The canonical syntax reference is part of the Ruby Sass documentation:
44http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html
45
46
47Obligatory
48----------
49
50Copyright © 2012 German M. Bravo (Kronuz). Additional credits in the
51documentation.
52
53Licensed under the `MIT license`_, reproduced in ``LICENSE``.
54
55.. _MIT license: http://www.opensource.org/licenses/mit-license.php
560
=== removed directory '.pc/python3-fixup.patch'
=== removed directory '.pc/python3-fixup.patch/scss'
=== removed directory '.pc/python3-fixup.patch/scss/src'
=== removed file '.pc/python3-fixup.patch/scss/src/_speedups.c'
--- .pc/python3-fixup.patch/scss/src/_speedups.c 2014-06-26 12:10:36 +0000
+++ .pc/python3-fixup.patch/scss/src/_speedups.c 1970-01-01 00:00:00 +0000
@@ -1,554 +0,0 @@
1/*
2* pyScss, a Scss compiler for Python
3* SCSS blocks scanner.
4*
5* German M. Bravo (Kronuz) <german.mb@gmail.com>
6* https://github.com/Kronuz/pyScss
7*
8* MIT license (http://www.opensource.org/licenses/mit-license.php)
9* Copyright (c) 2011 German M. Bravo (Kronuz), All rights reserved.
10*/
11#include <Python.h>
12#include "block_locator.h"
13#include "scanner.h"
14
15/* BlockLocator */
16staticforward PyTypeObject scss_BlockLocatorType;
17
18typedef struct {
19 PyObject_HEAD
20 BlockLocator *locator;
21} scss_BlockLocator;
22
23static int
24scss_BlockLocator_init(scss_BlockLocator *self, PyObject *args, PyObject *kwds)
25{
26 char *codestr;
27 int codestr_sz;
28
29 self->locator = NULL;
30
31 if (!PyArg_ParseTuple(args, "s#", &codestr, &codestr_sz)) {
32 return -1;
33 }
34
35 self->locator = BlockLocator_new(codestr, codestr_sz);
36
37 #ifdef DEBUG
38 PySys_WriteStderr("Scss BlockLocator object initialized! (%lu bytes)\n", sizeof(scss_BlockLocator));
39 #endif
40
41 return 0;
42}
43
44static void
45scss_BlockLocator_dealloc(scss_BlockLocator *self)
46{
47 if (self->locator != NULL) BlockLocator_del(self->locator);
48
49 self->ob_type->tp_free((PyObject*)self);
50
51 #ifdef DEBUG
52 PySys_WriteStderr("Scss BlockLocator object destroyed!\n");
53 #endif
54}
55
56scss_BlockLocator*
57scss_BlockLocator_iter(scss_BlockLocator *self)
58{
59 Py_INCREF(self);
60 return self;
61}
62
63PyObject*
64scss_BlockLocator_iternext(scss_BlockLocator *self)
65{
66 Block *block;
67
68 if (self->locator != NULL) {
69 block = BlockLocator_iternext(self->locator);
70
71 if (block->error > 0) {
72 return Py_BuildValue(
73 "is#s#",
74 block->lineno,
75 block->selprop,
76 block->selprop_sz,
77 block->codestr,
78 block->codestr_sz
79 );
80 }
81
82 if (block->error > 0) {
83 PyErr_SetString(PyExc_Exception, self->locator->exc);
84 return NULL;
85 }
86 }
87
88 /* Raising of standard StopIteration exception with empty value. */
89 PyErr_SetNone(PyExc_StopIteration);
90 return NULL;
91}
92
93/* Type definition */
94
95static PyTypeObject scss_BlockLocatorType = {
96 PyObject_HEAD_INIT(NULL)
97 0, /* ob_size */
98 "scss._BlockLocator", /* tp_name */
99 sizeof(scss_BlockLocator), /* tp_basicsize */
100 0, /* tp_itemsize */
101 (destructor)scss_BlockLocator_dealloc, /* tp_dealloc */
102 0, /* tp_print */
103 0, /* tp_getattr */
104 0, /* tp_setattr */
105 0, /* tp_compare */
106 0, /* tp_repr */
107 0, /* tp_as_number */
108 0, /* tp_as_sequence */
109 0, /* tp_as_mapping */
110 0, /* tp_hash */
111 0, /* tp_call */
112 0, /* tp_str */
113 0, /* tp_getattro */
114 0, /* tp_setattro */
115 0, /* tp_as_buffer */
116 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /* tp_flags */
117 "Internal BlockLocator iterator object.", /* tp_doc */
118 0, /* tp_traverse */
119 0, /* tp_clear */
120 0, /* tp_richcompare */
121 0, /* tp_weaklistoffset */
122 (getiterfunc)scss_BlockLocator_iter, /* tp_iter: __iter__() method */
123 (iternextfunc)scss_BlockLocator_iternext, /* tp_iternext: next() method */
124 0, /* tp_methods */
125 0, /* tp_members */
126 0, /* tp_getset */
127 0, /* tp_base */
128 0, /* tp_dict */
129 0, /* tp_descr_get */
130 0, /* tp_descr_set */
131 0, /* tp_dictoffset */
132 (initproc)scss_BlockLocator_init, /* tp_init */
133};
134
135
136/* Scanner */
137static PyObject *PyExc_scss_NoMoreTokens;
138
139staticforward PyTypeObject scss_ScannerType;
140
141typedef struct {
142 PyObject_HEAD
143 Scanner *scanner;
144} scss_Scanner;
145
146
147static PyObject *
148scss_Scanner_rewind(scss_Scanner *self, PyObject *args)
149{
150 int token_num;
151 if (self->scanner != NULL) {
152 if (PyArg_ParseTuple(args, "i", &token_num)) {
153 Scanner_rewind(self->scanner, token_num);
154 }
155 }
156 Py_INCREF(Py_None);
157 return (PyObject *)Py_None;
158}
159
160
161static PyObject *
162scss_Scanner_token(scss_Scanner *self, PyObject *args)
163{
164 PyObject *iter;
165 PyObject *item;
166 long size;
167
168 Token *p_token;
169
170 int token_num;
171 PyObject *restrictions = NULL;
172 Pattern *_restrictions = NULL;
173 int restrictions_sz = 0;
174 if (self->scanner != NULL) {
175 if (PyArg_ParseTuple(args, "i|O", &token_num, &restrictions)) {
176 if (restrictions != NULL) {
177 size = PySequence_Size(restrictions);
178 if (size != -1) {
179 _restrictions = PyMem_New(Pattern, size);
180 iter = PyObject_GetIter(restrictions);
181 while ((item = PyIter_Next(iter))) {
182 if (PyString_Check(item)) {
183 _restrictions[restrictions_sz].tok = PyString_AsString(item);
184 _restrictions[restrictions_sz].expr = NULL;
185 restrictions_sz++;
186 }
187 Py_DECREF(item);
188 }
189 Py_DECREF(iter);
190 }
191 }
192 p_token = Scanner_token(self->scanner, token_num, _restrictions, restrictions_sz);
193
194 if (_restrictions != NULL) PyMem_Del(_restrictions);
195
196 if (p_token == (Token *)SCANNER_EXC_BAD_TOKEN) {
197 PyErr_SetString(PyExc_SyntaxError, self->scanner->exc);
198 return NULL;
199 }
200 if (p_token == (Token *)SCANNER_EXC_RESTRICTED) {
201 PyErr_SetString(PyExc_SyntaxError, self->scanner->exc);
202 return NULL;
203 }
204 if (p_token == (Token *)SCANNER_EXC_UNIMPLEMENTED) {
205 PyErr_SetString(PyExc_NotImplementedError, self->scanner->exc);
206 return NULL;
207 }
208 if (p_token == (Token *)SCANNER_EXC_NO_MORE_TOKENS) {
209 PyErr_SetNone(PyExc_scss_NoMoreTokens);
210 return NULL;
211 }
212 if (p_token < 0) {
213 PyErr_SetNone(PyExc_Exception);
214 return NULL;
215 }
216 return Py_BuildValue(
217 "iiss#",
218 p_token->string - self->scanner->input,
219 p_token->string - self->scanner->input + p_token->string_sz,
220 p_token->regex->tok,
221 p_token->string,
222 p_token->string_sz
223 );
224 }
225 }
226 Py_INCREF(Py_None);
227 return (PyObject *)Py_None;
228}
229
230static PyObject *
231scss_Scanner_reset(scss_Scanner *self, PyObject *args, PyObject *kwds)
232{
233 char *input = NULL;
234 int input_sz = 0;
235
236 if (self->scanner != NULL) {
237 if (PyArg_ParseTuple(args, "|z#", &input, &input_sz)) {
238 Scanner_reset(self->scanner, input, input_sz);
239 }
240 }
241
242 Py_INCREF(Py_None);
243 return (PyObject *)Py_None;
244}
245
246static PyObject *
247scss_Scanner_setup_patterns(PyObject *self, PyObject *patterns)
248{
249 PyObject *item, *item0, *item1;
250 int i, is_tuple, _is_tuple;
251 long size;
252
253 Pattern *_patterns = NULL;
254 int patterns_sz = 0;
255 if (!Scanner_initialized()) {
256 is_tuple = PyTuple_Check(patterns);
257 if (is_tuple || PyList_Check(patterns)) {
258 size = is_tuple ? PyTuple_Size(patterns) : PyList_Size(patterns);
259 _patterns = PyMem_New(Pattern, size);
260 for (i = 0; i < size; ++i) {
261 item = is_tuple ? PyTuple_GetItem(patterns, i) : PyList_GetItem(patterns, i);
262 _is_tuple = PyTuple_Check(item);
263 if (_is_tuple || PyList_Check(item)) {
264 item0 = _is_tuple ? PyTuple_GetItem(item, 0) : PyList_GetItem(item, 0);
265 item1 = _is_tuple ? PyTuple_GetItem(item, 1) : PyList_GetItem(item, 1);
266 if (PyString_Check(item0) && PyString_Check(item1)) {
267 _patterns[patterns_sz].tok = PyString_AsString(item0);
268 _patterns[patterns_sz].expr = PyString_AsString(item1);
269 patterns_sz++;
270 }
271 }
272 }
273 }
274 Scanner_initialize(_patterns, patterns_sz);
275 if (_patterns != NULL) PyMem_Del(_patterns);
276 }
277 Py_INCREF(Py_None);
278 return (PyObject *)Py_None;
279}
280
281static int
282scss_Scanner_init(scss_Scanner *self, PyObject *args, PyObject *kwds)
283{
284 PyObject *item, *item0, *item1;
285 int i, is_tuple, _is_tuple;
286 long size;
287
288 PyObject *patterns, *ignore;
289 Pattern *_patterns = NULL;
290 int patterns_sz = 0;
291 Pattern *_ignore = NULL;
292 int ignore_sz = 0;
293 char *input = NULL;
294 int input_sz = 0;
295
296 self->scanner = NULL;
297
298 if (!PyArg_ParseTuple(args, "OO|z#", &patterns, &ignore, &input, &input_sz)) {
299 return -1;
300 }
301
302 if (!Scanner_initialized()) {
303 is_tuple = PyTuple_Check(patterns);
304 if (is_tuple || PyList_Check(patterns)) {
305 size = is_tuple ? PyTuple_Size(patterns) : PyList_Size(patterns);
306 _patterns = PyMem_New(Pattern, size);
307 for (i = 0; i < size; ++i) {
308 item = is_tuple ? PyTuple_GetItem(patterns, i) : PyList_GetItem(patterns, i);
309 _is_tuple = PyTuple_Check(item);
310 if (_is_tuple || PyList_Check(item)) {
311 item0 = _is_tuple ? PyTuple_GetItem(item, 0) : PyList_GetItem(item, 0);
312 item1 = _is_tuple ? PyTuple_GetItem(item, 1) : PyList_GetItem(item, 1);
313 if (PyString_Check(item0) && PyString_Check(item1)) {
314 _patterns[patterns_sz].tok = PyString_AsString(item0);
315 _patterns[patterns_sz].expr = PyString_AsString(item1);
316 patterns_sz++;
317 }
318 }
319 }
320 }
321 Scanner_initialize(_patterns, patterns_sz);
322 }
323
324 is_tuple = PyTuple_Check(ignore);
325 if (is_tuple || PyList_Check(ignore)) {
326 size = is_tuple ? PyTuple_Size(ignore) : PyList_Size(ignore);
327 _ignore = PyMem_New(Pattern, size);
328 for (i = 0; i < size; ++i) {
329 item = is_tuple ? PyTuple_GetItem(ignore, i) : PyList_GetItem(ignore, i);
330 if (PyString_Check(item)) {
331 _ignore[ignore_sz].tok = PyString_AsString(item);
332 _ignore[ignore_sz].expr = NULL;
333 ignore_sz++;
334 }
335 }
336 }
337
338 self->scanner = Scanner_new(_patterns, patterns_sz, _ignore, ignore_sz, input, input_sz);
339
340 if (_patterns != NULL) PyMem_Del(_patterns);
341 if (_ignore != NULL) PyMem_Del(_ignore);
342
343 #ifdef DEBUG
344 PySys_WriteStderr("Scss Scanner object initialized! (%lu bytes)\n", sizeof(scss_Scanner));
345 #endif
346
347 return 0;
348}
349
350static PyObject *
351scss_Scanner_repr(scss_Scanner *self)
352{
353 /* Print the last 10 tokens that have been scanned in */
354 PyObject *repr, *tmp;
355 Token *p_token;
356 int i, start, pos;
357
358 if (self->scanner != NULL && self->scanner->tokens_sz) {
359 start = self->scanner->tokens_sz - 10;
360 repr = PyString_FromString("");
361 for (i = (start < 0) ? 0 : start; i < self->scanner->tokens_sz; i++) {
362 p_token = &self->scanner->tokens[i];
363 PyString_ConcatAndDel(&repr, PyString_FromString("\n"));
364 pos = (int)(p_token->string - self->scanner->input);
365 PyString_ConcatAndDel(&repr, PyString_FromFormat(" (@%d) %s = ",
366 pos, p_token->regex->tok));
367 tmp = PyString_FromStringAndSize(p_token->string, p_token->string_sz);
368 PyString_ConcatAndDel(&repr, PyObject_Repr(tmp));
369 Py_XDECREF(tmp);
370 }
371 } else {
372 repr = PyString_FromString("None");
373 }
374
375 return (PyObject *)repr;
376
377/*
378 PyObject *repr, *tmp, *tmp2;
379 Token *p_token;
380 char *tok;
381 int i, start, first = 1, cur, max=0, pos;
382
383 if (self->scanner != NULL && self->scanner->tokens_sz) {
384 start = self->scanner->tokens_sz - 10;
385 repr = PyString_FromString("");
386 for (i = (start < 0) ? 0 : start; i < self->scanner->tokens_sz; i++) {
387 p_token = self->scanner->tokens[i];
388 PyString_ConcatAndDel(&repr, PyString_FromString("\n"));
389 pos = (int)(p_token->string - self->scanner->input);
390 PyString_ConcatAndDel(&repr, PyString_FromFormat(" (@%d) %s = ",
391 pos, p_token->regex->tok));
392 tmp = PyString_FromString(p_token->string);
393 PyString_ConcatAndDel(&repr, PyObject_Repr(tmp));
394 Py_XDECREF(tmp);
395 }
396
397 start = self->scanner->tokens_sz - 10;
398 for (i = (start < 0) ? 0 : start; i < self->scanner->tokens_sz; i++) {
399 p_token = self->scanner->tokens[i];
400 cur = strlen(p_token->regex->tok) * 2;
401 if (cur > max) max = cur;
402 }
403 tok = PyMem_New(char, max + 4);
404 repr = PyString_FromString("");
405 for (i = (start < 0) ? 0 : start; i < self->scanner->tokens_sz; i++) {
406 p_token = self->scanner->tokens[i];
407 if (!first) PyString_ConcatAndDel(&repr, PyString_FromString("\n"));
408
409 pos = (int)(p_token->string - self->scanner->input);
410 if (pos < 10) PyString_ConcatAndDel(&repr, PyString_FromString(" "));
411 if (pos < 100) PyString_ConcatAndDel(&repr, PyString_FromString(" "));
412 if (pos < 1000) PyString_ConcatAndDel(&repr, PyString_FromString(" "));
413 PyString_ConcatAndDel(&repr, PyString_FromFormat("(@%d) ",
414 pos));
415
416 tmp = PyString_FromString(p_token->regex->tok);
417 tmp2 = PyObject_Repr(tmp);
418 memset(tok, ' ', max + 4);
419 tok[max + 3 - PyString_Size(tmp2)] = '\0';
420 PyString_ConcatAndDel(&repr, PyString_FromString(tok));
421 PyString_ConcatAndDel(&repr, tmp2);
422 Py_XDECREF(tmp);
423
424 PyString_ConcatAndDel(&repr, PyString_FromString(" = "));
425 tmp = PyString_FromString(p_token->string);
426 PyString_ConcatAndDel(&repr, PyObject_Repr(tmp));
427 Py_XDECREF(tmp);
428
429 first = 0;
430 }
431 PyMem_Del(tok);
432 } else {
433 repr = PyString_FromString("None");
434 }
435
436 return (PyObject *)repr;
437*/
438}
439
440static void
441scss_Scanner_dealloc(scss_Scanner *self)
442{
443 if (self->scanner != NULL) Scanner_del(self->scanner);
444
445 self->ob_type->tp_free((PyObject*)self);
446
447 #ifdef DEBUG
448 PySys_WriteStderr("Scss Scanner object destroyed!\n");
449 #endif
450}
451
452static PyMethodDef scss_Scanner_methods[] = {
453 {"reset", (PyCFunction)scss_Scanner_reset, METH_VARARGS, "Scan the next token"},
454 {"token", (PyCFunction)scss_Scanner_token, METH_VARARGS, "Get the nth token"},
455 {"rewind", (PyCFunction)scss_Scanner_rewind, METH_VARARGS, "Rewind scanner"},
456 {"setup_patterns", (PyCFunction)scss_Scanner_setup_patterns, METH_O | METH_STATIC, "Initialize patterns."},
457 {NULL, NULL, 0, NULL} /* Sentinel */
458};
459
460static PyTypeObject scss_ScannerType = {
461 PyObject_HEAD_INIT(NULL)
462 0, /* ob_size */
463 "scss.Scanner", /* tp_name */
464 sizeof(scss_Scanner), /* tp_basicsize */
465 0, /* tp_itemsize */
466 (destructor)scss_Scanner_dealloc, /* tp_dealloc */
467 0, /* tp_print */
468 0, /* tp_getattr */
469 0, /* tp_setattr */
470 0, /* tp_compare */
471 (reprfunc)scss_Scanner_repr, /* tp_repr */
472 0, /* tp_as_number */
473 0, /* tp_as_sequence */
474 0, /* tp_as_mapping */
475 0, /* tp_hash */
476 0, /* tp_call */
477 0, /* tp_str */
478 0, /* tp_getattro */
479 0, /* tp_setattro */
480 0, /* tp_as_buffer */
481 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
482 "Scanner object.", /* tp_doc */
483 0, /* tp_traverse */
484 0, /* tp_clear */
485 0, /* tp_richcompare */
486 0, /* tp_weaklistoffset */
487 0, /* tp_iter: __iter__() method */
488 0, /* tp_iternext: next() method */
489 scss_Scanner_methods, /* tp_methods */
490 0, /* tp_members */
491 0, /* tp_getset */
492 0, /* tp_base */
493 0, /* tp_dict */
494 0, /* tp_descr_get */
495 0, /* tp_descr_set */
496 0, /* tp_dictoffset */
497 (initproc)scss_Scanner_init, /* tp_init */
498};
499
500
501/* Python constructor */
502
503static PyObject *
504scss_locate_blocks(PyObject *self, PyObject *args)
505{
506 scss_BlockLocator *result = NULL;
507
508 result = PyObject_New(scss_BlockLocator, &scss_BlockLocatorType);
509 if (result) {
510 scss_BlockLocator_init(result, args, NULL);
511 }
512
513 return (PyObject *)result;
514}
515
516
517/* Module functions */
518
519static PyMethodDef scss_methods[] = {
520 {"locate_blocks", (PyCFunction)scss_locate_blocks, METH_VARARGS, "Locate Scss blocks."},
521 {NULL, NULL, 0, NULL} /* Sentinel */
522};
523
524
525/* Module init function */
526
527PyMODINIT_FUNC
528init_speedups(void)
529{
530 PyObject* m;
531
532 scss_BlockLocatorType.tp_new = PyType_GenericNew;
533 if (PyType_Ready(&scss_BlockLocatorType) < 0)
534 return;
535
536 scss_ScannerType.tp_new = PyType_GenericNew;
537 if (PyType_Ready(&scss_ScannerType) < 0)
538 return;
539
540 BlockLocator_initialize();
541 Scanner_initialize(NULL, 0);
542
543 m = Py_InitModule("_speedups", scss_methods);
544
545 Py_INCREF(&scss_BlockLocatorType);
546 PyModule_AddObject(m, "_BlockLocator", (PyObject *)&scss_BlockLocatorType);
547
548 Py_INCREF(&scss_ScannerType);
549 PyModule_AddObject(m, "Scanner", (PyObject *)&scss_ScannerType);
550
551 PyExc_scss_NoMoreTokens = PyErr_NewException("_speedups.NoMoreTokens", NULL, NULL);
552 Py_INCREF(PyExc_scss_NoMoreTokens);
553 PyModule_AddObject(m, "NoMoreTokens", (PyObject *)PyExc_scss_NoMoreTokens);
554}
5550
=== removed file '.pc/python3-fixup.patch/scss/src/py3defs.h'
=== modified file 'README.rst'
--- README.rst 2014-06-28 06:51:52 +0000
+++ README.rst 2014-10-02 13:40:33 +0000
@@ -47,7 +47,7 @@
47Obligatory47Obligatory
48----------48----------
4949
50Copyright (c) 2012 German M. Bravo (Kronuz). Additional credits in the50Copyright © 2012 German M. Bravo (Kronuz). Additional credits in the
51documentation.51documentation.
5252
53Licensed under the `MIT license`_, reproduced in ``LICENSE``.53Licensed under the `MIT license`_, reproduced in ``LICENSE``.
5454
=== modified file 'scss/src/_speedups.c'
--- scss/src/_speedups.c 2014-09-17 11:11:52 +0000
+++ scss/src/_speedups.c 2014-10-02 13:40:33 +0000
@@ -9,12 +9,11 @@
9* Copyright (c) 2011 German M. Bravo (Kronuz), All rights reserved.9* Copyright (c) 2011 German M. Bravo (Kronuz), All rights reserved.
10*/10*/
11#include <Python.h>11#include <Python.h>
12#include "py3defs.h"
13#include "block_locator.h"12#include "block_locator.h"
14#include "scanner.h"13#include "scanner.h"
1514
16/* BlockLocator */15/* BlockLocator */
17static PyTypeObject scss_BlockLocatorType;16staticforward PyTypeObject scss_BlockLocatorType;
1817
19typedef struct {18typedef struct {
20 PyObject_HEAD19 PyObject_HEAD
@@ -47,7 +46,7 @@
47{46{
48 if (self->locator != NULL) BlockLocator_del(self->locator);47 if (self->locator != NULL) BlockLocator_del(self->locator);
4948
50 Py_TYPE(self)->tp_free((PyObject*)self);49 self->ob_type->tp_free((PyObject*)self);
5150
52 #ifdef DEBUG51 #ifdef DEBUG
53 PySys_WriteStderr("Scss BlockLocator object destroyed!\n");52 PySys_WriteStderr("Scss BlockLocator object destroyed!\n");
@@ -94,7 +93,8 @@
94/* Type definition */93/* Type definition */
9594
96static PyTypeObject scss_BlockLocatorType = {95static PyTypeObject scss_BlockLocatorType = {
97 PyVarObject_HEAD_INIT(NULL, 0)96 PyObject_HEAD_INIT(NULL)
97 0, /* ob_size */
98 "scss._BlockLocator", /* tp_name */98 "scss._BlockLocator", /* tp_name */
99 sizeof(scss_BlockLocator), /* tp_basicsize */99 sizeof(scss_BlockLocator), /* tp_basicsize */
100 0, /* tp_itemsize */100 0, /* tp_itemsize */
@@ -136,7 +136,7 @@
136/* Scanner */136/* Scanner */
137static PyObject *PyExc_scss_NoMoreTokens;137static PyObject *PyExc_scss_NoMoreTokens;
138138
139static PyTypeObject scss_ScannerType;139staticforward PyTypeObject scss_ScannerType;
140140
141typedef struct {141typedef struct {
142 PyObject_HEAD142 PyObject_HEAD
@@ -179,13 +179,8 @@
179 _restrictions = PyMem_New(Pattern, size);179 _restrictions = PyMem_New(Pattern, size);
180 iter = PyObject_GetIter(restrictions);180 iter = PyObject_GetIter(restrictions);
181 while ((item = PyIter_Next(iter))) {181 while ((item = PyIter_Next(iter))) {
182#if PY_MAJOR_VERSION >= 3
183 if (PyBytes_Check(item)) {
184 _restrictions[restrictions_sz].tok = PyBytes_AsString(item);
185#else
186 if (PyString_Check(item)) {182 if (PyString_Check(item)) {
187 _restrictions[restrictions_sz].tok = PyString_AsString(item);183 _restrictions[restrictions_sz].tok = PyString_AsString(item);
188#endif
189 _restrictions[restrictions_sz].expr = NULL;184 _restrictions[restrictions_sz].expr = NULL;
190 restrictions_sz++;185 restrictions_sz++;
191 }186 }
@@ -268,15 +263,9 @@
268 if (_is_tuple || PyList_Check(item)) {263 if (_is_tuple || PyList_Check(item)) {
269 item0 = _is_tuple ? PyTuple_GetItem(item, 0) : PyList_GetItem(item, 0);264 item0 = _is_tuple ? PyTuple_GetItem(item, 0) : PyList_GetItem(item, 0);
270 item1 = _is_tuple ? PyTuple_GetItem(item, 1) : PyList_GetItem(item, 1);265 item1 = _is_tuple ? PyTuple_GetItem(item, 1) : PyList_GetItem(item, 1);
271#if PY_MAJOR_VERSION >= 3
272 if (PyBytes_Check(item0) && PyBytes_Check(item1)) {
273 _patterns[patterns_sz].tok = PyBytes_AsString(item0);
274 _patterns[patterns_sz].expr = PyBytes_AsString(item1);
275#else
276 if (PyString_Check(item0) && PyString_Check(item1)) {266 if (PyString_Check(item0) && PyString_Check(item1)) {
277 _patterns[patterns_sz].tok = PyString_AsString(item0);267 _patterns[patterns_sz].tok = PyString_AsString(item0);
278 _patterns[patterns_sz].expr = PyString_AsString(item1);268 _patterns[patterns_sz].expr = PyString_AsString(item1);
279#endif
280 patterns_sz++;269 patterns_sz++;
281 }270 }
282 }271 }
@@ -321,15 +310,9 @@
321 if (_is_tuple || PyList_Check(item)) {310 if (_is_tuple || PyList_Check(item)) {
322 item0 = _is_tuple ? PyTuple_GetItem(item, 0) : PyList_GetItem(item, 0);311 item0 = _is_tuple ? PyTuple_GetItem(item, 0) : PyList_GetItem(item, 0);
323 item1 = _is_tuple ? PyTuple_GetItem(item, 1) : PyList_GetItem(item, 1);312 item1 = _is_tuple ? PyTuple_GetItem(item, 1) : PyList_GetItem(item, 1);
324#if PY_MAJOR_VERSION >= 3
325 if (PyBytes_Check(item0) && PyBytes_Check(item1)) {
326 _patterns[patterns_sz].tok = PyBytes_AsString(item0);
327 _patterns[patterns_sz].expr = PyBytes_AsString(item1);
328#else
329 if (PyString_Check(item0) && PyString_Check(item1)) {313 if (PyString_Check(item0) && PyString_Check(item1)) {
330 _patterns[patterns_sz].tok = PyString_AsString(item0);314 _patterns[patterns_sz].tok = PyString_AsString(item0);
331 _patterns[patterns_sz].expr = PyString_AsString(item1);315 _patterns[patterns_sz].expr = PyString_AsString(item1);
332#endif
333 patterns_sz++;316 patterns_sz++;
334 }317 }
335 }318 }
@@ -344,13 +327,8 @@
344 _ignore = PyMem_New(Pattern, size);327 _ignore = PyMem_New(Pattern, size);
345 for (i = 0; i < size; ++i) {328 for (i = 0; i < size; ++i) {
346 item = is_tuple ? PyTuple_GetItem(ignore, i) : PyList_GetItem(ignore, i);329 item = is_tuple ? PyTuple_GetItem(ignore, i) : PyList_GetItem(ignore, i);
347#if PY_MAJOR_VERSION >= 3
348 if (PyBytes_Check(item)) {
349 _ignore[ignore_sz].tok = PyBytes_AsString(item);
350#else
351 if (PyString_Check(item)) {330 if (PyString_Check(item)) {
352 _ignore[ignore_sz].tok = PyString_AsString(item);331 _ignore[ignore_sz].tok = PyString_AsString(item);
353#endif
354 _ignore[ignore_sz].expr = NULL;332 _ignore[ignore_sz].expr = NULL;
355 ignore_sz++;333 ignore_sz++;
356 }334 }
@@ -379,22 +357,6 @@
379357
380 if (self->scanner != NULL && self->scanner->tokens_sz) {358 if (self->scanner != NULL && self->scanner->tokens_sz) {
381 start = self->scanner->tokens_sz - 10;359 start = self->scanner->tokens_sz - 10;
382#if PY_MAJOR_VERSION >= 3
383 repr = PyBytes_FromString("");
384 for (i = (start < 0) ? 0 : start; i < self->scanner->tokens_sz; i++) {
385 p_token = &self->scanner->tokens[i];
386 PyBytes_ConcatAndDel(&repr, PyBytes_FromString("\n"));
387 pos = (int)(p_token->string - self->scanner->input);
388 PyBytes_ConcatAndDel(&repr, PyBytes_FromFormat(" (@%d) %s = ",
389 pos, p_token->regex->tok));
390 tmp = PyBytes_FromStringAndSize(p_token->string, p_token->string_sz);
391 PyBytes_ConcatAndDel(&repr, PyObject_Repr(tmp));
392 Py_XDECREF(tmp);
393 }
394 } else {
395 repr = PyBytes_FromString("None");
396 }
397#else
398 repr = PyString_FromString("");360 repr = PyString_FromString("");
399 for (i = (start < 0) ? 0 : start; i < self->scanner->tokens_sz; i++) {361 for (i = (start < 0) ? 0 : start; i < self->scanner->tokens_sz; i++) {
400 p_token = &self->scanner->tokens[i];362 p_token = &self->scanner->tokens[i];
@@ -409,7 +371,6 @@
409 } else {371 } else {
410 repr = PyString_FromString("None");372 repr = PyString_FromString("None");
411 }373 }
412#endif
413374
414 return (PyObject *)repr;375 return (PyObject *)repr;
415376
@@ -481,7 +442,7 @@
481{442{
482 if (self->scanner != NULL) Scanner_del(self->scanner);443 if (self->scanner != NULL) Scanner_del(self->scanner);
483444
484 Py_TYPE(self)->tp_free((PyObject*)self);445 self->ob_type->tp_free((PyObject*)self);
485446
486 #ifdef DEBUG447 #ifdef DEBUG
487 PySys_WriteStderr("Scss Scanner object destroyed!\n");448 PySys_WriteStderr("Scss Scanner object destroyed!\n");
@@ -497,7 +458,8 @@
497};458};
498459
499static PyTypeObject scss_ScannerType = {460static PyTypeObject scss_ScannerType = {
500 PyVarObject_HEAD_INIT(NULL, 0)461 PyObject_HEAD_INIT(NULL)
462 0, /* ob_size */
501 "scss.Scanner", /* tp_name */463 "scss.Scanner", /* tp_name */
502 sizeof(scss_Scanner), /* tp_basicsize */464 sizeof(scss_Scanner), /* tp_basicsize */
503 0, /* tp_itemsize */465 0, /* tp_itemsize */
@@ -559,53 +521,27 @@
559 {NULL, NULL, 0, NULL} /* Sentinel */521 {NULL, NULL, 0, NULL} /* Sentinel */
560};522};
561523
562#if PY_MAJOR_VERSION >= 3
563
564/* Module definition */
565
566static struct PyModuleDef speedups_module_def = {
567 PyModuleDef_HEAD_INIT,
568 "_speedups", /* m_name */
569 NULL, /* m_doc */
570 (Py_ssize_t) -1, /* m_size */
571 scss_methods, /* m_methods */
572 NULL, /* m_reload */
573 NULL, /* m_traverse */
574 NULL, /* m_clear */
575 NULL, /* m_free */
576};
577
578#endif
579524
580/* Module init function */525/* Module init function */
581526
582#if PY_MAJOR_VERSION >= 3527PyMODINIT_FUNC
583 #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)528init_speedups(void)
584#else
585 #define MOD_INIT(name) PyMODINIT_FUNC init##name(void)
586#endif
587
588MOD_INIT(_speedups)
589{529{
590#if PY_MAJOR_VERSION >= 3530 PyObject* m;
591 PyObject* m = PyModule_Create(&speedups_module_def);
592#else
593 PyObject* m = Py_InitModule("_speedups", scss_methods);
594#endif
595531
596 scss_BlockLocatorType.tp_new = PyType_GenericNew;532 scss_BlockLocatorType.tp_new = PyType_GenericNew;
533 if (PyType_Ready(&scss_BlockLocatorType) < 0)
534 return;
535
597 scss_ScannerType.tp_new = PyType_GenericNew;536 scss_ScannerType.tp_new = PyType_GenericNew;
598#if PY_MAJOR_VERSION >= 3537 if (PyType_Ready(&scss_ScannerType) < 0)
599 if (PyType_Ready(&scss_BlockLocatorType) < 0 || PyType_Ready(&scss_ScannerType) < 0)
600 return m;
601#else
602 if (PyType_Ready(&scss_BlockLocatorType) < 0 || PyType_Ready(&scss_ScannerType) < 0)
603 return;538 return;
604#endif
605539
606 BlockLocator_initialize();540 BlockLocator_initialize();
607 Scanner_initialize(NULL, 0);541 Scanner_initialize(NULL, 0);
608542
543 m = Py_InitModule("_speedups", scss_methods);
544
609 Py_INCREF(&scss_BlockLocatorType);545 Py_INCREF(&scss_BlockLocatorType);
610 PyModule_AddObject(m, "_BlockLocator", (PyObject *)&scss_BlockLocatorType);546 PyModule_AddObject(m, "_BlockLocator", (PyObject *)&scss_BlockLocatorType);
611547
@@ -615,8 +551,4 @@
615 PyExc_scss_NoMoreTokens = PyErr_NewException("_speedups.NoMoreTokens", NULL, NULL);551 PyExc_scss_NoMoreTokens = PyErr_NewException("_speedups.NoMoreTokens", NULL, NULL);
616 Py_INCREF(PyExc_scss_NoMoreTokens);552 Py_INCREF(PyExc_scss_NoMoreTokens);
617 PyModule_AddObject(m, "NoMoreTokens", (PyObject *)PyExc_scss_NoMoreTokens);553 PyModule_AddObject(m, "NoMoreTokens", (PyObject *)PyExc_scss_NoMoreTokens);
618#if PY_MAJOR_VERSION >= 3
619
620 return m;
621#endif
622}554}
623555
=== removed file 'scss/src/py3defs.h'
--- scss/src/py3defs.h 2014-09-17 11:11:52 +0000
+++ scss/src/py3defs.h 1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
1/*
2* pyScss, a Scss compiler for Python
3* SCSS blocks scanner.
4*
5* German M. Bravo (Kronuz) <german.mb@gmail.com>
6* https://github.com/Kronuz/pyScss
7*
8* MIT license (http://www.opensource.org/licenses/mit-license.php)
9* Copyright (c) 2011 German M. Bravo (Kronuz), All rights reserved.
10*/
11#ifndef PY3DEFS_H
12#define PY3DEFS_H
13
14/* Iterators are turned on by default in Python 3. */
15#if PY_MAJOR_VERSION >= 3
16 #define Py_TPFLAGS_HAVE_ITER 0
17#endif
18
19/* Py_TYPE exists in 2.6+, but for 2.5 and below we can use the old ob_type. */
20#ifndef Py_TYPE
21 #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
22#endif
23
24/* PyVarObject_HEAD_INIT also exists in 2.6+, so for 2.5 use PyObject_HEAD_INIT. */
25#ifndef PyVarObject_HEAD_INIT
26 #define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
27#endif
28
29#endif

Subscribers

People subscribed via source and target branches

to all changes: