Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

increase size of index, line, and column fields #310

Merged
merged 8 commits into from Dec 13, 2019
Merged
8 changes: 4 additions & 4 deletions ext/_yaml.pyx
Expand Up @@ -63,13 +63,13 @@ MappingNode = yaml.nodes.MappingNode

cdef class Mark:
cdef readonly object name
cdef readonly int index
cdef readonly int line
cdef readonly int column
cdef readonly size_t index
cdef readonly size_t line
cdef readonly size_t column
cdef readonly buffer
cdef readonly pointer

def __init__(self, object name, int index, int line, int column,
def __init__(self, object name, size_t index, size_t line, size_t column,
object buffer, object pointer):
self.name = name
self.index = index
Expand Down
16 changes: 15 additions & 1 deletion tests/lib/test_yaml_ext.py
@@ -1,6 +1,6 @@

import _yaml, yaml
import types, pprint
import types, pprint, tempfile, sys

yaml.PyBaseLoader = yaml.BaseLoader
yaml.PySafeLoader = yaml.SafeLoader
Expand Down Expand Up @@ -233,6 +233,20 @@ def test_c_emitter(data_filename, canonical_filename, verbose=False):
test_c_emitter.unittest = ['.data', '.canonical']
test_c_emitter.skip = ['.skip-ext']

def test_large_file(verbose=False):
SIZE_LINE = 24
SIZE_ITERATION = 0
SIZE_FILE = 31
if sys.maxsize <= 2**32:
return
with tempfile.TemporaryFile() as temp_file:
for i in range(2**(SIZE_FILE-SIZE_ITERATION-SIZE_LINE) + 1):
temp_file.write(('-' + (' ' * (2**SIZE_LINE-4))+ '{}\n')*(2**SIZE_ITERATION))
temp_file.seek(0)
yaml.load(temp_file, Loader=yaml.CLoader)

test_large_file.unittest = None

def wrap_ext_function(function):
def wrapper(*args, **kwds):
_set_up()
Expand Down
16 changes: 15 additions & 1 deletion tests/lib3/test_yaml_ext.py
@@ -1,6 +1,6 @@

import _yaml, yaml
import types, pprint
import types, pprint, tempfile, sys

yaml.PyBaseLoader = yaml.BaseLoader
yaml.PySafeLoader = yaml.SafeLoader
Expand Down Expand Up @@ -233,6 +233,20 @@ def test_c_emitter(data_filename, canonical_filename, verbose=False):
test_c_emitter.unittest = ['.data', '.canonical']
test_c_emitter.skip = ['.skip-ext']

def test_large_file(verbose=False):
SIZE_LINE = 24
SIZE_ITERATION = 0
SIZE_FILE = 31
if sys.maxsize <= 2**32:
return
with tempfile.TemporaryFile() as temp_file:
dwightguth marked this conversation as resolved.
Show resolved Hide resolved
for i in range(2**(SIZE_FILE-SIZE_ITERATION-SIZE_LINE) + 1):
temp_file.write(bytes(('-' + (' ' * (2**SIZE_LINE-4))+ '{}\n')*(2**SIZE_ITERATION), 'utf-8'))
temp_file.seek(0)
yaml.load(temp_file, Loader=yaml.CLoader)

test_large_file.unittest = None

def wrap_ext_function(function):
def wrapper(*args, **kwds):
_set_up()
Expand Down