Skip to content

Commit 8dd301a

Browse files
committed
Remove utils.xml_generator and utils.xml_output_version
These two variables should not have made it into the public API. There is no deprecation cycle for these because of the complexity of keeping these module attributes around. This allows now to completely get rid of the writing of these values during the different caching processes.
1 parent 292493c commit 8dd301a

11 files changed

+5
-133
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ Version 1.9.0 (not yet released)
2323
and ```remove_elaborated``` function.
2424
This is only available when setting the ```castxml_epic_version``` flag to 1 .
2525

26+
* Removed ```utils.xml_generator``` and ```utils.xml_output_version``` attributes.
27+
These two variables should not have made it into the public API. There is no
28+
deprecation cycle for these because of the complexity of keeping these
29+
module attributes around.
30+
2631
* Deprecated ```decl``` attribute from ```dependency_info_t```. Use ```declaration```
2732
instead.
2833

pygccxml/parser/declarations_cache.py

-24
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,11 @@ class record_t(object):
102102

103103
def __init__(
104104
self,
105-
xml_generator,
106105
source_signature,
107106
config_signature,
108107
included_files,
109108
included_files_signature,
110109
declarations):
111-
self.__xml_generator = xml_generator
112110
self.__source_signature = source_signature
113111
self.__config_signature = config_signature
114112
self.__included_files = included_files
@@ -153,10 +151,6 @@ def included_files_signature(self):
153151
def declarations(self):
154152
return self.__declarations
155153

156-
@property
157-
def xml_generator(self):
158-
return self.__xml_generator
159-
160154

161155
class file_cache_t(cache_base_t):
162156

@@ -180,23 +174,6 @@ def __init__(self, name):
180174
self.__cache) # If empty then we need to flush
181175
for entry in self.__cache.values(): # Clear hit flags
182176
entry.was_hit = False
183-
try:
184-
# Make sure the xml_generator variable is defined, else it
185-
# will stay None.
186-
xml_generator = entry.xml_generator
187-
except AttributeError:
188-
msg = (
189-
"The %s cache file is not compatible with this version " +
190-
"of pygccxml. Please regenerate it.") % name
191-
raise RuntimeError(msg)
192-
if not utils.xml_generator:
193-
# Set the xml_generator to the one read in the cache file
194-
utils.xml_generator = xml_generator
195-
elif utils.xml_generator != xml_generator:
196-
msg = (
197-
"The %s cache file was generated with a different xml " +
198-
"generator. Please regenerate it.") % name
199-
raise RuntimeError(msg)
200177

201178
@staticmethod
202179
def __load(file_name):
@@ -258,7 +235,6 @@ def update(self, source_file, configuration, declarations, included_files):
258235
""" Update a cached record with the current key and value contents. """
259236

260237
record = record_t(
261-
xml_generator=utils.xml_generator,
262238
source_signature=file_signature(source_file),
263239
config_signature=configuration_signature(configuration),
264240
included_files=included_files,

pygccxml/parser/directory_cache.py

-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import pickle
2828

2929
from . import declarations_cache
30-
from .. import utils
3130

3231

3332
class index_entry_t(object):
@@ -252,10 +251,6 @@ def _load(self):
252251
self.__index = {}
253252
self.__filename_rep = filename_repository_t(self.__sha1_sigs)
254253

255-
# Read the xml generator from the cache and set it
256-
with open(os.path.join(self.__dir, "gen.dat"), "r") as gen_file:
257-
utils.xml_generator = gen_file.read()
258-
259254
self.__modified_flag = False
260255

261256
def _save(self):
@@ -274,10 +269,6 @@ def _save(self):
274269
(self.__index,
275270
self.__filename_rep))
276271

277-
# Read the xml generator from the cache and set it
278-
with open(os.path.join(self.__dir, "gen.dat"), "w") as gen_file:
279-
gen_file.write(utils.xml_generator)
280-
281272
self.__modified_flag = False
282273

283274
def _read_file(self, filename):

pygccxml/parser/scanner.py

-1
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,5 @@ def __read_version(self, attrs):
680680
gccxml_cvs_revision = attrs.get(XML_AN_CVS_REVISION)
681681
xml_generator = utils.xml_generators(
682682
utils.loggers.cxx_parser, gccxml_cvs_revision, castxml_format)
683-
utils.xml_generator = xml_generator.get_string_repr()
684683
utils.xml_output_version = gccxml_cvs_revision
685684
self.__xml_generator_from_xml_file = xml_generator

pygccxml/utils/__init__.py

-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,3 @@
1818
from .utils import get_tr1
1919
from .utils import cxx_standard
2020
from .xml_generators import xml_generators
21-
22-
# Version of xml generator which was used.
23-
xml_generator = ""
24-
xml_output_version = ""

unittests/core_tester.py

-3
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,6 @@ def test_abstract_classes(self):
524524
not implementation.is_abstract,
525525
"class 'implementation' should not be abstract")
526526

527-
def test_versioning(self):
528-
self.assertTrue(utils.xml_generator)
529-
530527
def test_byte_size(self):
531528
mptrs = self.global_ns.class_('members_pointers_t')
532529
self.assertTrue(mptrs.byte_size != 0)

unittests/data/new_cache.cache

-2.32 KB
Binary file not shown.

unittests/data/old_cache.cache

-2.29 KB
Binary file not shown.

unittests/file_cache_tester.py

-26
Original file line numberDiff line numberDiff line change
@@ -82,32 +82,6 @@ def test_from_file(self):
8282
("cached declarations and source declarations are different, " +
8383
"after pickling"))
8484

85-
@staticmethod
86-
def test_reopen_cache():
87-
"""
88-
Test opening cache files in a subprocess (with a clean environment).
89-
90-
"""
91-
92-
env = os.environ.copy()
93-
94-
# Get the path to current directory
95-
path = os.path.dirname(os.path.realpath(__file__))
96-
# Set the COVERAGE_PROCESS_START env. variable.
97-
# Allows to cover files run in a subprocess
98-
# http://nedbatchelder.com/code/coverage/subprocess.html
99-
env["COVERAGE_PROCESS_START"] = path + "/../.coveragerc"
100-
101-
p = subprocess.Popen(
102-
[sys.executable, "unittests/reopen_cache_tester.py"],
103-
stderr=subprocess.PIPE,
104-
env=env)
105-
p.wait()
106-
error = p.stderr.read().decode("utf-8").rstrip()
107-
p.stderr.close()
108-
if p.returncode != 0:
109-
raise Exception(error)
110-
11185

11286
def create_suite():
11387
suite = unittest.TestSuite()

unittests/reopen_cache_tester.py

-59
This file was deleted.

unittests/test_directory_cache.py

-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from . import parser_test_case
1313

1414
from pygccxml import parser
15-
from pygccxml import utils
1615

1716

1817
class Test(parser_test_case.parser_test_case_t):
@@ -41,7 +40,6 @@ def test_directory_cache_without_compression(self):
4140
parser.parse([self.header], self.config, cache=cache)
4241
# Read from the cache the second time
4342
parser.parse([self.header], self.config, cache=cache)
44-
self.assertIsNotNone(utils.xml_generator)
4543

4644
def test_directory_cache_with_compression(self):
4745
"""
@@ -55,7 +53,6 @@ def test_directory_cache_with_compression(self):
5553
parser.parse([self.header], self.config, cache=cache)
5654
# Read from the cache the second time
5755
parser.parse([self.header], self.config, cache=cache)
58-
self.assertIsNotNone(utils.xml_generator)
5956

6057
def test_dir_compatibility(self):
6158
"""
@@ -74,8 +71,6 @@ def test_dir_compatibility(self):
7471
# Reset this warning to always
7572
warnings.simplefilter("error", DeprecationWarning)
7673

77-
self.assertIsNotNone(utils.xml_generator)
78-
7974
def test_directory_cache_twice(self):
8075
"""
8176
Setup two caches in a row.
@@ -87,8 +82,6 @@ def test_directory_cache_twice(self):
8782
cache = parser.directory_cache_t(directory=self.cache_dir)
8883
parser.parse([self.header], self.config, cache=cache)
8984

90-
self.assertIsNotNone(utils.xml_generator)
91-
9285
def test_directory_existing_dir(self):
9386
"""
9487
Setup a cache when there is already a file at the cache's location.

0 commit comments

Comments
 (0)