ソースを参照

Start some Py3k compatibility stuff.

tags/v0.2
Ben Kurtovic 12年前
コミット
1f47e10f04
5個のファイルの変更11行の追加29行の削除
  1. +3
    -1
      mwparserfromhell/parser/__init__.py
  2. +0
    -24
      mwparserfromhell/parser/builder.c
  3. +1
    -1
      mwparserfromhell/parser/tokenizer.c
  4. +4
    -0
      mwparserfromhell/parser/tokenizer.h
  5. +3
    -3
      setup.py

+ 3
- 1
mwparserfromhell/parser/__init__.py ファイルの表示

@@ -28,9 +28,11 @@ joins them together under one interface.

try:
from ._builder import CBuilder as Builder
from ._tokenizer import CTokenizer as Tokenizer
except ImportError:
from .builder import Builder
try:
from ._tokenizer import CTokenizer as Tokenizer
except ImportError:
from .tokenizer import Tokenizer

__all__ = ["Parser"]


+ 0
- 24
mwparserfromhell/parser/builder.c ファイルの表示

@@ -1,24 +0,0 @@
/*
Builder for MWParserFromHell
Copyright (C) 2012 Ben Kurtovic <ben.kurtovic@verizon.net>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#include <Python.h>

+ 1
- 1
mwparserfromhell/parser/tokenizer.c ファイルの表示

@@ -1394,7 +1394,7 @@ init_tokenizer(void)
numdefs = (unsigned) PyList_GET_SIZE(defmap);
entitydefs = calloc(numdefs + 1, sizeof(char*));
for (i = 0; i < numdefs; i++)
entitydefs[i] = PyString_AsString(PyList_GET_ITEM(deflist, i));
entitydefs[i] = PyBytes_AsString(PyList_GET_ITEM(deflist, i));
Py_DECREF(deflist);

EMPTY = PyUnicode_FromString("");


+ 4
- 0
mwparserfromhell/parser/tokenizer.h ファイルの表示

@@ -29,6 +29,10 @@ SOFTWARE.
#include <math.h>
#include <structmember.h>

#if PY_MAJOR_VERSION >= 3
#define IS_PY3K
#endif

#define malloc PyObject_Malloc
#define free PyObject_Free



+ 3
- 3
setup.py ファイルの表示

@@ -28,8 +28,8 @@ from mwparserfromhell import __version__
with open("README.rst") as fp:
long_docs = fp.read()

builder = Extension("mwparserfromhell.parser._builder",
sources = ["mwparserfromhell/parser/builder.c"])
# builder = Extension("mwparserfromhell.parser._builder",
# sources = ["mwparserfromhell/parser/builder.c"])

tokenizer = Extension("mwparserfromhell.parser._tokenizer",
sources = ["mwparserfromhell/parser/tokenizer.c"])
@@ -37,7 +37,7 @@ tokenizer = Extension("mwparserfromhell.parser._tokenizer",
setup(
name = "mwparserfromhell",
packages = find_packages(exclude=("tests",)),
ext_modules = [builder, tokenizer],
ext_modules = [tokenizer],
test_suite = "tests",
version = __version__,
author = "Ben Kurtovic",


読み込み中…
キャンセル
保存